List of usage examples for java.awt.geom Point2D getY
public abstract double getY();
From source file:com.aerohive.nms.web.config.lbs.services.HmFolderServiceImpl.java
private static Point2D llip(Point2D l1p1, Point2D l1p2, Point2D l2p1, Point2D l2p2) { // Line between l1p1 and l1p2 double a1 = l1p2.getY() - l1p1.getY(); double b1 = l1p1.getX() - l1p2.getX(); double c1 = a1 * l1p1.getX() + b1 * l1p1.getY(); // Line between l2p1 and l2p2 double a2 = l2p2.getY() - l2p1.getY(); double b2 = l2p1.getX() - l2p2.getX(); double c2 = a2 * l2p1.getX() + b2 * l2p1.getY(); // Intersection point double det = a1 * b2 - a2 * b1; double x = (b2 * c1 - b1 * c2) / det; double y = (a1 * c2 - a2 * c1) / det; return new Point2D.Double(x, y); }
From source file:edu.pitt.dbmi.odie.ui.jfreechart.EnhancedChartComposite.java
/** * Bounds the selection rectangle between the first and the last chart * entity bounds. and between the top and bottom bounds of the chart area. *///from w w w . j a va 2s .c o m private void boundSelectionRectangle() { int FIRSTENTITYERROR = 2; if (selectedEntities.size() > 0) { ChartEntity first = selectedEntities.get(0); ChartEntity last = selectedEntities.get(selectedEntities.size() - 1); Point firstp = first.getArea().getBounds().getLocation(); Point lastp = last.getArea().getBounds().getLocation(); Rectangle screenArea = getScreenDataArea(); Point2D screenPoint = translateScreenToJava2D(new Point(screenArea.x, screenArea.y)); if (this.orientation == PlotOrientation.VERTICAL) { selectionRectangle = new Rectangle(firstp.x - FIRSTENTITYERROR, (int) screenPoint.getY(), lastp.x + last.getArea().getBounds().width - firstp.x, (int) (screenArea.height / scaleY)); } else { selectionRectangle = new Rectangle((int) screenPoint.getX(), firstp.y, (int) (screenArea.width / scaleX), lastp.y + last.getArea().getBounds().height - firstp.y); } } }
From source file:lcmc.gui.ResourceGraph.java
/** Scale function. */ protected final ViewScalingControl getScalingControl() { return new ViewScalingControl() { void superScale(final VisualizationServer thisVV, final float amount, final Point2D from) { super.scale(thisVV, amount, from); }//from ww w .j a v a2s . c o m @Override public void scale(final VisualizationServer thisVV, final float amount, final Point2D from) { final JScrollBar sbV = getScrollPane().getVerticalScrollBar(); final JScrollBar sbH = getScrollPane().getHorizontalScrollBar(); final Point2D last = posWithScrollbar(getLastPosition()); final double fromX = from.getX() < last.getX() ? from.getX() : last.getX(); final double fromY = from.getY() < last.getY() ? from.getY() : last.getY(); final double width = getVisualizationViewer().getSize().getWidth(); final double height = getVisualizationViewer().getSize().getHeight(); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { final Point2D prevPoint = getVisualizationViewer().getRenderContext() .getMultiLayerTransformer().inverseTransform(Layer.VIEW, from); final double scaledSoFar = getScaledSoFar(); float am = amount; if (am < 1) { if (scaledSoFar < 0.3) { am = 1; } else { superScale(thisVV, 1 / am, new Point2D.Double(0, 0)); } } else if (am > 1) { if (scaledSoFar > 5) { am = 1; } else { superScale(thisVV, 1 / am, new Point2D.Double(0, 0)); } } setScaledSoFar(scaledSoFar * am); final Point2D p2 = getVisualizationViewer().getRenderContext().getMultiLayerTransformer() .inverseTransform(Layer.VIEW, from); final int valueY = (int) (sbV.getValue() + prevPoint.getY() - p2.getY()); sbV.setValue(valueY); sbV.repaint(); final int valueX = (int) (sbH.getValue() + prevPoint.getX() - p2.getX()); sbH.setValue(valueX); sbH.repaint(); thisVV.repaint(); } }); } }; }
From source file:com.isti.traceview.common.TraceViewChartPanel.java
/** * Translates a Java2D point on the chart to a screen location. * /*from w w w .ja v a2 s . c o m*/ * @param java2DPoint * the Java2D point. * @return The screen location. */ public Point translateJava2DToScreen(Point2D java2DPoint) { Insets insets = getInsets(); int x = (int) (java2DPoint.getX() * this.scaleX + insets.left); int y = (int) (java2DPoint.getY() * this.scaleY + insets.top); return new Point(x, y); }
From source file:org.jcurl.zui.piccolo.BroomPromptSimple.java
public BroomPromptSimple() { final boolean stickUp = false; final boolean bothSides = true; final int pieAngle = 150; final Color sp = Color.BLACK; final Color bgc = new Color(1, 1, 1, 0.5f); final Stroke fine = new BasicStroke(0.01f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER); final Stroke bold = new BasicStroke(0.03f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER); // final Font fo = new Font("SansSerif", Font.BOLD, 1); final float halo = RockProps.DEFAULT.getRadius(); final float outer = 0.8f * RockProps.DEFAULT.getRadius(); stickLength = (stickUp ? 1 : -1) * 5 * outer; final float inner = 0.5F * outer; setPickable(false);//www. j a v a 2s . co m final BroomPromptSimple self = this; handle = new PNode() { private static final long serialVersionUID = -7641452321842902940L; /** * Return true if this node or any pickable descendends are picked. * If a pick occurs the pickPath is modified so that this node is * always returned as the picked node, event if it was a decendent * node that initialy reported the pick. * * @see PComposite */ @Override public boolean fullPick(final PPickPath pickPath) { if (super.fullPick(pickPath)) { PNode picked = pickPath.getPickedNode(); // this code won't work with internal cameras, because // it doesn't pop // the cameras view transform. while (picked != self) { pickPath.popTransform(picked.getTransformReference(false)); pickPath.popNode(picked); picked = pickPath.getPickedNode(); } return true; } return false; } }; { // opaque Background final PNode bg = node(new Arc2D.Float(-halo, -halo, 2 * halo, 2 * halo, 0, 360, Arc2D.OPEN), null, null, scale0); bg.setPaint(bgc); bg.setPickable(true); handle.addChild(bg); } { // Cross-hair circles and pie final int off = 90; final int pieOff = 180; final int arrowLengthDegrees = 7; // colored pie: pie = node(new Arc2D.Float(-outer, -outer, 2 * outer, 2 * outer, off - pieOff, pieAngle, Arc2D.PIE), null, null, scale0); handle.addChild(pie); // inner circle: handle.addChild( node(new Arc2D.Float(-inner, -inner, 2 * inner, 2 * inner, off, pieOff + pieAngle, Arc2D.OPEN), fine, sp, scale50)); // outer circle: handle.addChild(node(new Arc2D.Float(-outer, -outer, 2 * outer, 2 * outer, off, pieOff + pieAngle - (14 + arrowLengthDegrees), Arc2D.OPEN), fine, sp, scale50)); handle.addChild( node(new Arc2D.Float(-outer, -outer, 2 * outer, 2 * outer, off, pieOff + pieAngle, Arc2D.OPEN), fine, sp, -scale50)); final double ar = Math.PI * (off + pieAngle) / 180.0; // radius // if (pieAngle % 90 != 0) handle.addChild( node(new Line2D.Double(0, 0, -outer * Math.cos(ar), outer * Math.sin(ar)), bold, sp, scale0)); // arrow: final float f = outer / 10; final PPath s = node(IceShapes.createArrowHead(f, 3 * f, 0.5f * f), null, null, scale50); s.setPaint(sp); final double a = Math.PI * (off + pieAngle - arrowLengthDegrees) / 180.0; s.translate(-outer * Math.cos(a), outer * Math.sin(a)); s.rotate(Math.PI * (90 - (off + pieAngle) + 8 + arrowLengthDegrees) / 180.0); handle.addChild(s); this.addChild(handle); } { // y-axis: handle.addChild( node(new Line2D.Float(0, -Math.signum(stickLength) * halo, 0, stickLength), fine, sp, scale0)); // x-axis: handle.addChild(node(new Line2D.Float(-halo, 0, halo, 0), fine, sp, scale0)); } { // slider slider = new PPath(IceShapes.createSlider(0.4f * outer, bothSides), fine); slider.setStrokePaint(sp); slider.setPickable(true); this.addChild(slider); } // Set up Event handling addInputEventListener(new PDragEventHandler() { /** double-click: flip handle */ @Override public void mouseClicked(final PInputEvent arg0) { super.mouseClicked(arg0); if (arg0.getClickCount() > 1) { arg0.setHandled(true); first = new HandleMemento(getModel(), getModel().getOutTurn()); last = new HandleMemento(getModel(), !getModel().getOutTurn()); ChangeManager.getTrivial(changer).undoable(first, last); first = last = null; } } /** drag/move */ @Override public void mouseDragged(final PInputEvent arg0) { arg0.setHandled(true); getModel().setValueIsAdjusting(true); if (false) { final Point2D p = arg0.getPositionRelativeTo(self.getParent()); getModel().setBroom(p); } else view2model(new XYMemento(getModel(), arg0.getPositionRelativeTo(self.getParent()))); } @Override public void mouseEntered(final PInputEvent arg0) { super.mouseEntered(arg0); arg0.pushCursor(MOVE_CURSOR); } @Override public void mouseExited(final PInputEvent arg0) { super.mouseExited(arg0); arg0.popCursor(); } @Override public void mousePressed(final PInputEvent arg0) { arg0.setHandled(true); first = new XYMemento(getModel(), getModel().getBroom()); } @Override public void mouseReleased(final PInputEvent pinputevent) { getModel().setValueIsAdjusting(false); if (first != null && last != null && first != last) ChangeManager.getTrivial(changer).undoable(first, last); first = last = null; } }); slider.addInputEventListener(new PDragEventHandler() { @Override protected void endDrag(final PInputEvent pinputevent) { log.debug("speed"); } /** adjust the slider */ @Override public void mouseDragged(final PInputEvent arg0) { arg0.setHandled(true); final Point2D p = arg0.getPositionRelativeTo(self); final BoundedRangeModel r = self.getModel().getSplitTimeMillis(); if (r == null) return; r.setValueIsAdjusting(true); view2model(new SplitMemento(getModel(), ratio2value(p.getY() / stickLength, r))); } @Override public void mouseEntered(final PInputEvent arg0) { super.mouseEntered(arg0); arg0.pushCursor(UPDN_CURSOR); } @Override public void mouseExited(final PInputEvent arg0) { super.mouseExited(arg0); arg0.popCursor(); } @Override public void mousePressed(final PInputEvent arg0) { arg0.setHandled(true); first = new SplitMemento(getModel(), getModel().getSplitTimeMillis().getValue()); } @Override public void mouseReleased(final PInputEvent pinputevent) { log.debug("speed"); final BoundedRangeModel r = self.getModel().getSplitTimeMillis(); if (r == null) return; r.setValueIsAdjusting(false); if (first != null && last != null && first != last) ChangeManager.getTrivial(changer).undoable(first, last); first = last = null; } }); }
From source file:org.gumtree.vis.hist2d.Hist2DPanel.java
private void changeSelectedMask(Point2D point) { switch (getMaskDragIndicator()) { case Cursor.MOVE_CURSOR: moveMask(point);/*w ww . j a v a 2 s .c o m*/ break; case Cursor.W_RESIZE_CURSOR: if (((XYPlot) getChart().getPlot()).getDomainAxis().isInverted()) { changeMaskXMax(point.getX()); } else { changeMaskXMin(point.getX()); } break; case Cursor.E_RESIZE_CURSOR: if (((XYPlot) getChart().getPlot()).getDomainAxis().isInverted()) { changeMaskXMin(point.getX()); } else { changeMaskXMax(point.getX()); } break; case Cursor.N_RESIZE_CURSOR: if (((XYPlot) getChart().getPlot()).getRangeAxis().isInverted()) { changeMaskYMin(point.getY()); } else { changeMaskYMax(point.getY()); } break; case Cursor.S_RESIZE_CURSOR: if (((XYPlot) getChart().getPlot()).getRangeAxis().isInverted()) { changeMaskYMax(point.getY()); } else { changeMaskYMin(point.getY()); } break; case Cursor.NW_RESIZE_CURSOR: if (((XYPlot) getChart().getPlot()).getDomainAxis().isInverted()) { changeMaskXMax(point.getX()); } else { changeMaskXMin(point.getX()); } if (((XYPlot) getChart().getPlot()).getRangeAxis().isInverted()) { changeMaskYMin(point.getY()); } else { changeMaskYMax(point.getY()); } break; case Cursor.NE_RESIZE_CURSOR: if (((XYPlot) getChart().getPlot()).getDomainAxis().isInverted()) { changeMaskXMin(point.getX()); } else { changeMaskXMax(point.getX()); } if (((XYPlot) getChart().getPlot()).getRangeAxis().isInverted()) { changeMaskYMin(point.getY()); } else { changeMaskYMax(point.getY()); } break; case Cursor.SW_RESIZE_CURSOR: if (((XYPlot) getChart().getPlot()).getDomainAxis().isInverted()) { changeMaskXMax(point.getX()); } else { changeMaskXMin(point.getX()); } if (((XYPlot) getChart().getPlot()).getRangeAxis().isInverted()) { changeMaskYMax(point.getY()); } else { changeMaskYMin(point.getY()); } break; case Cursor.SE_RESIZE_CURSOR: if (((XYPlot) getChart().getPlot()).getDomainAxis().isInverted()) { changeMaskXMin(point.getX()); } else { changeMaskXMax(point.getX()); } if (((XYPlot) getChart().getPlot()).getRangeAxis().isInverted()) { changeMaskYMax(point.getY()); } else { changeMaskYMin(point.getY()); } break; default: break; } fireMaskUpdateEvent(getSelectedMask()); }
From source file:edu.pitt.dbmi.odie.ui.jfreechart.EnhancedChartComposite.java
public void mouseDown(MouseEvent event) { Point2D javaPoint = translateScreenToJava2D(new Point(event.x, event.y)); Rectangle scaledDataArea = getScreenDataArea(event.x, event.y); if (scaledDataArea == null) return;/* w w w .ja v a2 s . c o m*/ // new entity code ChartEntity entity = getEntityForLocation(javaPoint.getX(), javaPoint.getY()); if (entity != null) logger.debug("Entity Bounds:" + entity.getArea().getBounds()); // logger.debug("----------END------------"); if (event.button == 1) { // Init zoom point only if CTRL key is down. if ((event.stateMask & SWT.CONTROL) != 0) { this.zoomPoint = getPointInRectangle(event.x, event.y, scaledDataArea); } else { clearSelection(false, false); this.selectionPoint = getPointInRectangle(event.x, event.y, scaledDataArea); } } this.anchor = javaPoint; this.chart.setNotify(true); // force a redraw this.canvas.redraw(); Object[] listeners = this.chartMouseListeners.getListeners(ChartMouseListener.class); if (listeners.length == 0) { return; } // pass mouse down event if some ChartMouseListener are listening java.awt.event.MouseEvent mouseEvent = SWTUtils.toAwtMouseEvent(event); ChartMouseEvent chartEvent = new ChartMouseEvent(getChart(), mouseEvent, entity); for (int i = listeners.length - 1; i >= 0; i -= 1) { ((ChartMouseListener) listeners[i]).chartMouseClicked(chartEvent); } }
From source file:org.gumtree.vis.awt.JChartPanel.java
@Override public void mouseClicked(MouseEvent e) { if ((e.getModifiers() & InputEvent.ALT_MASK) != 0) { double xNew = ChartMaskingUtilities.translateScreenX(e.getX(), getScreenDataArea(), getChart()); double yNew = ChartMaskingUtilities.translateScreenY(e.getY(), getScreenDataArea(), getChart(), 0); addMarker(xNew, yNew, null);// w w w . ja v a2 s . co m } else if (isTextInputEnabled) { if (!textInputFlag) { boolean newTextEnabled = selectedTextWrapper == null; if (selectedTextWrapper != null) { Point2D screenXY = ChartMaskingUtilities.translateChartPoint( new Point2D.Double(selectedTextWrapper.getMinX(), selectedTextWrapper.getMinY()), getScreenDataArea(), getChart()); Rectangle2D screenRect = new Rectangle2D.Double(screenXY.getX(), screenXY.getY() - 15, selectedTextWrapper.getWidth(), selectedTextWrapper.getHeight()); if (screenRect.contains(e.getX(), e.getY())) { Point2D point = e.getPoint(); String inputText = textContentMap.get(selectedTextWrapper); if (inputText == null) { inputText = ""; } String[] lines = inputText.split("\n", 100); int cursorX = 0; int charCount = 0; int maxWidth = 0; int pickX = -1; FontMetrics fm = getGraphics().getFontMetrics(); for (int i = 0; i < lines.length; i++) { int lineWidth = fm.stringWidth(lines[i]); if (lineWidth > maxWidth) { maxWidth = lineWidth; } } if (maxWidth < 100) { maxWidth = 100; } Point2D screenPoint = ChartMaskingUtilities.translateChartPoint( new Point2D.Double(selectedTextWrapper.getX(), selectedTextWrapper.getY()), getScreenDataArea(), getChart()); if (point.getX() <= screenPoint.getX() + 11 + maxWidth && point.getY() <= screenPoint.getY() + lines.length * 15 - 15) { textInputPoint = screenPoint; textInputContent = inputText; textInputFlag = true; textContentMap.remove(selectedTextWrapper); selectedTextWrapper = null; textInputCursorIndex = 0; for (int i = 0; i < lines.length; i++) { if (point.getY() > screenPoint.getY() + i * 15 - 15 && point.getY() <= screenPoint.getY() + i * 15) { cursorX = fm.stringWidth(lines[i]); if (point.getX() >= screenPoint.getX() && point.getX() <= screenPoint.getX() + 3 + cursorX) { if (point.getX() >= screenPoint.getX() && point.getX() < screenPoint.getX() + 3) { pickX = 0; } double lastEnd = screenPoint.getX() + 3; for (int j = 0; j < lines[i].length(); j++) { int size = fm.stringWidth(lines[i].substring(0, j + 1)); double newEnd = screenPoint.getX() + 3 + size; if (point.getX() >= lastEnd && point.getX() < lastEnd + (newEnd - lastEnd) / 2) { pickX = j; } else if (point.getX() >= lastEnd + (newEnd - lastEnd) / 2 && point.getX() < newEnd) { pickX = j + 1; } lastEnd = newEnd; } if (pickX >= 0) { textInputCursorIndex = charCount + pickX; } } else { textInputCursorIndex = charCount + lines[i].length(); } break; } charCount += lines[i].length() + 1; } } } } selectText(e.getX(), e.getY()); if (selectedTextWrapper == null && !textInputFlag && newTextEnabled && (e.getModifiers() & MouseEvent.BUTTON1_MASK) != 0) { textInputFlag = true; textInputPoint = e.getPoint(); } } else { Point2D point = e.getPoint(); boolean finishInput = false; // if (point.getX() < textInputPoint.getX() || point.getY() < textInputPoint.getY() - 15) { // finishInput = true; // } else { String inputText = textInputContent; if (inputText == null) { inputText = ""; } String[] lines = inputText.split("\n", 100); int cursorX = 0; int charCount = 0; int maxWidth = 0; int pickX = -1; FontMetrics fm = getGraphics().getFontMetrics(); for (int i = 0; i < lines.length; i++) { int lineWidth = fm.stringWidth(lines[i]); if (lineWidth > maxWidth) { maxWidth = lineWidth; } } if (maxWidth < 100) { maxWidth = 100; } if (point.getX() > textInputPoint.getX() + 11 + maxWidth || point.getY() > textInputPoint.getY() + lines.length * 15 - 15 || point.getX() < textInputPoint.getX() || point.getY() < textInputPoint.getY() - 15) { finishInput = true; } else { for (int i = 0; i < lines.length; i++) { if (point.getY() > textInputPoint.getY() + i * 15 - 15 && point.getY() <= textInputPoint.getY() + i * 15) { cursorX = fm.stringWidth(lines[i]); if (point.getX() >= textInputPoint.getX() && point.getX() <= textInputPoint.getX() + 3 + cursorX) { if (point.getX() >= textInputPoint.getX() && point.getX() < textInputPoint.getX() + 3) { pickX = 0; } double lastEnd = textInputPoint.getX() + 3; for (int j = 0; j < lines[i].length(); j++) { int size = fm.stringWidth(lines[i].substring(0, j + 1)); double newEnd = textInputPoint.getX() + 3 + size; if (point.getX() >= lastEnd && point.getX() < lastEnd + (newEnd - lastEnd) / 2) { pickX = j; } else if (point.getX() >= lastEnd + (newEnd - lastEnd) / 2 && point.getX() < newEnd) { pickX = j + 1; } lastEnd = newEnd; } if (pickX >= 0) { textInputCursorIndex = charCount + pickX; } } else { textInputCursorIndex = charCount + lines[i].length(); } break; } charCount += lines[i].length() + 1; } } // } if (finishInput) { if (textInputContent != null && textInputContent.length() > 0) { double xNew = ChartMaskingUtilities.translateScreenX(textInputPoint.getX(), getScreenDataArea(), getChart()); double yNew = ChartMaskingUtilities.translateScreenY(textInputPoint.getY(), getScreenDataArea(), getChart(), 0); textContentMap.put(new Rectangle2D.Double(xNew, yNew, maxWidth, lines.length * 15), textInputContent); } textInputContent = null; textInputCursorIndex = 0; textInputFlag = false; } } } }
From source file:com.aerohive.nms.web.config.lbs.services.HmFolderServiceImpl.java
private static Point2D llis(Point2D l1p1, Point2D l1p2, Point2D l2p1, Point2D l2p2) { double l1x1 = l1p1.getX(); double l1x2 = l1p2.getX(); if (l1x2 < l1x1) { l1x1 = l1x2;//from w w w. j a v a2 s .co m l1x2 = l1p1.getX(); } double l1y1 = l1p1.getY(); double l1y2 = l1p2.getY(); if (l1y2 < l1y1) { l1y1 = l1y2; l1y2 = l1p1.getY(); } double l2x1 = l2p1.getX(); double l2x2 = l2p2.getX(); if (l2x2 < l2x1) { l2x1 = l2x2; l2x2 = l2p1.getX(); } double l2y1 = l2p1.getY(); double l2y2 = l2p2.getY(); if (l2y2 < l2y1) { l2y1 = l2y2; l2y2 = l2p1.getY(); } Point2D ip = llip(l1p1, l1p2, l2p1, l2p2); double ipx = ip.getX(); double ipy = ip.getY(); double tol = 1e-6; if (Math.abs(l1x1 - l1x2) < tol) { ipx = l1x1; } else if (Math.abs(l2x1 - l2x2) < tol) { ipx = l2x1; } if (Math.abs(l1y1 - l1y2) < tol) { ipy = l1y1; } else if (Math.abs(l2y1 - l2y2) < tol) { ipy = l2y1; } if (ipx >= l1x1 && ipx <= l1x2 && ipx >= l2x1 && ipx <= l2x2 && ipy >= l1y1 && ipy <= l1y2 && ipy >= l2y1 && ipy <= l2y2) { return ip; } else { return null; } }
From source file:org.gumtree.vis.plot1d.Plot1DPanel.java
@Override public void mouseDragged(MouseEvent e) { Insets insets = getInsets();//from w ww .j a va2 s. c o m int x = (int) ((e.getX() - insets.left) / getScaleX()); int y = (int) ((e.getY() - insets.top) / getScaleY()); ChartEntity entity = null; EntityCollection entities = null; if (getChartRenderingInfo() != null) { entities = getChartRenderingInfo().getEntityCollection(); if (entities != null) { entity = entities.getEntity(x, y); // boolean isDirty = false; int seriesIndex = -1; if (selectedSeriesIndex >= 0) { // double xInChart = ChartMaskingUtilities.translateScreenX(x, // getScreenDataArea(), getChart()); // XYDataset dataset = getChart().getXYPlot().getDataset(); // PatternDataset patternDataset = (PatternDataset) dataset; // int itemIndex = patternDataset.getItemFromX(selectedSeriesIndex, xInChart); // if (itemIndex < patternDataset.getItemCount(selectedSeriesIndex)) { // chartX = patternDataset.getXValue(selectedSeriesIndex, itemIndex); // chartY = patternDataset.getYValue(selectedSeriesIndex, itemIndex); // Point2D axisTrace = ChartMaskingUtilities.translateChartPoint( // new Point2D.Double(chartX, chartY), getScreenDataArea(), getChart()); // horizontalTraceLocation = (int) axisTrace.getX(); // verticalTraceLocation = (int) axisTrace.getY(); // seriesIndex = selectedSeriesIndex; // isDirty = true; // } seriesIndex = followDomainTrace(selectedSeriesIndex, x); } else if (getChart().getXYPlot().getSeriesCount() == 1) { // int seriesIndex0 = 0; // double xInChart = ChartMaskingUtilities.translateScreenX(x, // getScreenDataArea(), getChart()); // XYDataset dataset = getChart().getXYPlot().getDataset(); // PatternDataset patternDataset = (PatternDataset) dataset; // int itemIndex = patternDataset.getItemFromX(seriesIndex0, xInChart); // if (itemIndex < patternDataset.getItemCount(seriesIndex0)) { // chartX = patternDataset.getXValue(seriesIndex0, itemIndex); // chartY = patternDataset.getYValue(seriesIndex0, itemIndex); // Point2D axisTrace = ChartMaskingUtilities.translateChartPoint( // new Point2D.Double(chartX, chartY), getScreenDataArea(), getChart()); // horizontalTraceLocation = (int) axisTrace.getX(); // verticalTraceLocation = (int) axisTrace.getY(); // seriesIndex = seriesIndex0; // isDirty = true; // } seriesIndex = followDomainTrace(0, x); } else if (entity instanceof XYItemEntity) { XYItemEntity xyEntity = (XYItemEntity) entity; XYDataset dataset = xyEntity.getDataset(); int item = ((XYItemEntity) entity).getItem(); seriesIndex = xyEntity.getSeriesIndex(); double chartX = dataset.getXValue(seriesIndex, item); double chartY = dataset.getYValue(seriesIndex, item); Point2D screenPoint = ChartMaskingUtilities.translateChartPoint( new Point2D.Double(chartX, chartY), getScreenDataArea(), getChart()); setChartX(chartX); setChartY(chartY); setSeriesIndex(seriesIndex); setItemIndex(item); if (dataset instanceof IXYErrorDataset) { setChartError(((IXYErrorDataset) dataset).getYError(seriesIndex, item)); } if (getHorizontalAxisTrace()) { setHorizontalTraceLocation((int) screenPoint.getX()); } if (getVerticalAxisTrace()) { setVerticalTraceLocation((int) screenPoint.getY()); } // isDirty = true; } if (seriesIndex >= 0) { Object[] listeners = getListeners(ChartMouseListener.class); if (getChart() != null) { XYChartMouseEvent event = new XYChartMouseEvent(getChart(), e, entity); event.setXY(getChartX(), getChartY()); event.setSeriesIndex(seriesIndex); for (int i = listeners.length - 1; i >= 0; i -= 1) { ((ChartMouseListener) listeners[i]).chartMouseMoved(event); } } } } } // if (isMaskingEnabled() && (e.getModifiers() & maskingKeyMask) != 0) { if (isInternalLegendEnabled && isInternalLegendSelected) { int cursorType = findCursorOnSelectedItem(e.getX(), e.getY()); setCursor(Cursor.getPredefinedCursor(cursorType)); } else if (isMaskingEnabled() && (e.getModifiers() & maskingKeyMask) == 0) { int cursorType = findCursorOnSelectedItem(e.getX(), e.getY()); setCursor(Cursor.getPredefinedCursor(cursorType)); } else if (getCursor() != defaultCursor) { setCursor(defaultCursor); } if (isInternalLegendEnabled && isInternalLegendSelected && findCursorOnSelectedItem(e.getX(), e.getY()) != Cursor.DEFAULT_CURSOR && (e.getModifiers() & MouseEvent.BUTTON1_MASK) != 0) { changeInternalLegend(e); } else if (getMaskDragIndicator() != Cursor.DEFAULT_CURSOR && this.getSelectedMask() != null && (e.getModifiers() & MouseEvent.BUTTON1_MASK) != 0) { changeSelectedMask(e); } else if (isMaskingEnabled() && (e.getModifiers() & maskingKeyMask) != 0) { // Do masking service // if no initial masking point was set, ignore dragging... makeNewMask(e); } else { super.mouseDragged(e); } }