| /** |
| ******************************************************************************** |
| * Copyright (c) 2022 Robert Bosch GmbH. |
| * |
| * This program and the accompanying materials are made |
| * available under the terms of the Eclipse Public License 2.0 |
| * which is available at https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Contributors: |
| * Robert Bosch GmbH - initial API and implementation |
| ******************************************************************************** |
| */ |
| |
| package org.eclipse.app4mc.emf.visualizations; |
| |
| import java.beans.PropertyChangeListener; |
| import java.beans.PropertyChangeSupport; |
| |
| /** |
| * Configuration of the visualization |
| * |
| */ |
| public class EObjectRefsConfig { |
| private final PropertyChangeSupport changeSupport = new PropertyChangeSupport(this); |
| |
| private boolean horizontalLayout = false; |
| private boolean showDerivedReferences = false; |
| private boolean showReferenceLabels = false; |
| private int scale = 100; // percent |
| |
| public boolean isHorizontalLayout() { |
| return horizontalLayout; |
| } |
| |
| public void setHorizontalLayout(boolean horizontal) { |
| horizontalLayout = horizontal; |
| firePropertyChange("parameter1", null, horizontalLayout); |
| } |
| |
| public boolean isShowDerivedReferences() { |
| return showDerivedReferences; |
| } |
| |
| public void setShowDerivedReferences(boolean showDerived) { |
| showDerivedReferences = showDerived; |
| firePropertyChange("parameter2", null, showDerivedReferences); |
| } |
| |
| public boolean isShowReferenceLabels() { |
| return showReferenceLabels; |
| } |
| |
| public void setShowReferenceLabels(boolean showLabels) { |
| showReferenceLabels = showLabels; |
| firePropertyChange("parameter3", null, showReferenceLabels); |
| } |
| |
| public int getScale() { |
| return scale; |
| } |
| |
| /** |
| * Sets a new scale value (if the new value is different and within the bounds [10, 200]) |
| * |
| * @param newScale |
| * @return true if value was changed |
| */ |
| public boolean setScale(int newScale) { |
| if (scale == newScale || newScale < 10 || newScale > 200) { |
| return false; |
| } |
| |
| int oldScale = scale; |
| scale = newScale; |
| firePropertyChange("scale", oldScale, newScale); |
| return true; |
| } |
| |
| public boolean decrementScale() { |
| return setScale(Math.max(10, scale - 10)); // minimum 10 % |
| } |
| |
| public boolean incrementScale() { |
| return setScale(Math.min(200, scale + 10)); // maximum 200 % |
| } |
| |
| // property change handling |
| |
| public void addChangeListener(PropertyChangeListener listener) { |
| changeSupport.addPropertyChangeListener(listener); |
| } |
| |
| public void removeChangeListener(PropertyChangeListener listener) { |
| changeSupport.removePropertyChangeListener(listener); |
| } |
| |
| protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) { |
| changeSupport.firePropertyChange(propertyName, oldValue, newValue); |
| } |
| |
| } |