X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.modeling.ui%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2Fui%2Fdiagram%2FSliderClass.java;h=a7329a979890c191957c99555eb9af0b6e2cd672;hb=28438fa467ae60dd63515be2df724c6ff9c299c9;hp=03edf6577963485a998a01c5b8409847b1beecca;hpb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagram/SliderClass.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagram/SliderClass.java index 03edf6577..a7329a979 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagram/SliderClass.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagram/SliderClass.java @@ -22,8 +22,8 @@ import java.util.Collection; import java.util.EnumSet; import javax.swing.JSlider; -import javax.vecmath.Vector2d; +import org.apache.commons.math3.geometry.euclidean.twod.Vector2D; import org.simantics.g2d.diagram.IDiagram; import org.simantics.g2d.element.ElementClass; import org.simantics.g2d.element.ElementHints; @@ -68,23 +68,23 @@ import org.simantics.utils.strings.format.MetricsFormatList; * @author J-P Laine */ public class SliderClass { - public static final Key KEY_SLIDER_RESOURCE_PATH = new KeyOf(Collection.class, "SLIDER_RESOURCE_PATH"); - public static final Key KEY_SLIDER_COMPONENT = new KeyOf(Object.class, "SLIDER_COMPONENT"); - public static final Key KEY_SLIDER_SUFFIX = new KeyOf(String.class, "SLIDER_SUFFIX"); - public static final Key KEY_SLIDER_RANGE = new KeyOf(Range.class, "SLIDER_SUBSTITUTIONS"); - public static final Key KEY_SLIDER_GC = new KeyOf(Graphics2D.class, "SLIDER_GC"); - public static final Key KEY_SLIDER_VALUE = new KeyOf(Double.class, "SLIDER_VALUE"); - public static final Key KEY_TOOLTIP_TEXT = new KeyOf(String.class, "TOOLTIP_TEXT"); - public static final Key KEY_NUMBER_FORMAT = new KeyOf(MetricsFormat.class, "NUMBER_FORMAT"); + public static final Key KEY_SLIDER_RESOURCE_PATH = new KeyOf(Collection.class, "SLIDER_RESOURCE_PATH"); //$NON-NLS-1$ + public static final Key KEY_SLIDER_COMPONENT = new KeyOf(Object.class, "SLIDER_COMPONENT"); //$NON-NLS-1$ + public static final Key KEY_SLIDER_SUFFIX = new KeyOf(String.class, "SLIDER_SUFFIX"); //$NON-NLS-1$ + public static final Key KEY_SLIDER_RANGE = new KeyOf(Range.class, "SLIDER_SUBSTITUTIONS"); //$NON-NLS-1$ + public static final Key KEY_SLIDER_GC = new KeyOf(Graphics2D.class, "SLIDER_GC"); //$NON-NLS-1$ + public static final Key KEY_SLIDER_VALUE = new KeyOf(Double.class, "SLIDER_VALUE"); //$NON-NLS-1$ + public static final Key KEY_TOOLTIP_TEXT = new KeyOf(String.class, "TOOLTIP_TEXT"); //$NON-NLS-1$ + public static final Key KEY_NUMBER_FORMAT = new KeyOf(MetricsFormat.class, "NUMBER_FORMAT"); //$NON-NLS-1$ /** * If this hint is defined, the monitor will force its x-axis to match this * angle. If this hint doesn't exist, the monitor will not force x-axis * orientation. */ - public static final Key KEY_DIRECTION = new KeyOf(Double.class, "SLIDER_DIRECTION"); + public static final Key KEY_DIRECTION = new KeyOf(Double.class, "SLIDER_DIRECTION"); //$NON-NLS-1$ - public static final Key KEY_SG_NODE = new SceneGraphNodeKey(Node.class, "SLIDER_SG_NODE"); + public static final Key KEY_SG_NODE = new SceneGraphNodeKey(Node.class, "SLIDER_SG_NODE"); //$NON-NLS-1$ public final static MetricsFormat DEFAULT_NUMBER_FORMAT = MetricsFormatList.METRICS_DECIMAL; public static class Range { @@ -383,11 +383,9 @@ public class SliderClass { return Double.NaN; double angrad = Math.toRadians(angle); - Vector2d forcedAxis = new Vector2d(Math.cos(angrad), Math.sin(angrad)); - Vector2d x = new Vector2d(tr.getScaleX(), tr.getShearX()); - forcedAxis.normalize(); - x.normalize(); - double cosa = forcedAxis.dot(x); + Vector2D forcedAxis = new Vector2D(Math.cos(angrad), Math.sin(angrad)); + Vector2D x = new Vector2D(tr.getScaleX(), tr.getShearX()).normalize(); + double cosa = forcedAxis.dotProduct(x); double delta = Math.acos(cosa); return delta; } @@ -422,7 +420,7 @@ public class SliderClass { @Override public Node init(G2DParentNode parent) { - SliderNode node = parent.getOrCreateNode(""+hashCode(), SliderNode.class); + SliderNode node = parent.getOrCreateNode(""+hashCode(), SliderNode.class); //$NON-NLS-1$ node.setValue(0); node.setBounds(new Rectangle2D.Double(0, 0, 50, 22)); node.setTransform(AffineTransform.getScaleInstance(staticScaleX, staticScaleY));