Example usage for java.awt Point getX

List of usage examples for java.awt Point getX

Introduction

In this page you can find the example usage for java.awt Point getX.

Prototype

public double getX() 

Source Link

Usage

From source file:msi.gama.outputs.layers.charts.FastXYItemRenderer.java

/** {@inheritDoc} */
@Override/*  w w  w.ja va2 s  . c  om*/
public void drawItem(final Graphics2D g2, final XYItemRendererState state, final Rectangle2D dataArea,
        final PlotRenderingInfo info, final XYPlot plot, final ValueAxis domainAxis, final ValueAxis rangeAxis,
        final XYDataset dataset, final int series, final int item, final CrosshairState crosshairState,
        final int pass) {

    if (!getItemVisible(series, item)) {
        return;
    }
    // setup for collecting optional entity info...
    boolean bAddEntity = false;
    Shape entityArea = null;
    EntityCollection entities = null;
    if (info != null) {
        entities = info.getOwner().getEntityCollection();
    }

    final PlotOrientation orientation = plot.getOrientation();
    final Paint paint = getItemPaint(series, item);
    final Stroke seriesStroke = getItemStroke(series, item);
    g2.setPaint(paint);
    g2.setStroke(seriesStroke);

    // get the data point...
    final double x1 = dataset.getXValue(series, item);
    final double y1 = dataset.getYValue(series, item);
    if (Double.isNaN(x1) || Double.isNaN(y1)) {
        return;
    }

    final RectangleEdge xAxisLocation = plot.getDomainAxisEdge();
    final RectangleEdge yAxisLocation = plot.getRangeAxisEdge();
    final double transX1 = domainAxis.valueToJava2D(x1, dataArea, xAxisLocation);
    final double transY1 = rangeAxis.valueToJava2D(y1, dataArea, yAxisLocation);

    if (getPlotLines()) {
        if (item == 0) {
            if (this.drawSeriesLineAsPath) {
                final State s = (State) state;
                s.seriesPath.reset();
                s.lastPointGood = false;
            }
            previousDrawnItem = 0;
        }

        if (this.drawSeriesLineAsPath) {
            final State s = (State) state;
            // update path to reflect latest point
            if (!Double.isNaN(transX1) && !Double.isNaN(transY1)) {
                float x = (float) transX1;
                float y = (float) transY1;
                if (orientation == PlotOrientation.HORIZONTAL) {
                    x = (float) transY1;
                    y = (float) transX1;
                }
                if (s.isLastPointGood()) {
                    // TODO: check threshold
                    s.seriesPath.lineTo(x, y);
                } else {
                    s.seriesPath.moveTo(x, y);
                }
                s.setLastPointGood(true);
            } else {
                s.setLastPointGood(false);
            }
            if (item == dataset.getItemCount(series) - 1) {
                // draw path
                g2.setStroke(getSeriesStroke(series));
                g2.setPaint(getSeriesPaint(series));
                g2.draw(s.seriesPath);
            }
        }

        else if (item != 0) {
            // get the previous data point...
            final double x0 = dataset.getXValue(series, item - previousDrawnItem);
            final double y0 = dataset.getYValue(series, item - previousDrawnItem);
            if (!Double.isNaN(x0) && !Double.isNaN(y0)) {
                boolean drawLine = true;
                if (getPlotDiscontinuous()) {
                    // only draw a line if the gap between the current and
                    // previous data point is within the threshold
                    final int numX = dataset.getItemCount(series);
                    final double minX = dataset.getXValue(series, 0);
                    final double maxX = dataset.getXValue(series, numX - 1);
                    if (this.gapThresholdType == UnitType.ABSOLUTE) {
                        drawLine = Math.abs(x1 - x0) <= this.gapThreshold;
                    } else {
                        drawLine = Math.abs(x1 - x0) <= (maxX - minX) / numX * getGapThreshold();
                    }
                }
                if (drawLine) {
                    final double transX0 = domainAxis.valueToJava2D(x0, dataArea, xAxisLocation);
                    final double transY0 = rangeAxis.valueToJava2D(y0, dataArea, yAxisLocation);

                    // only draw if we have good values
                    if (Double.isNaN(transX0) || Double.isNaN(transY0) || Double.isNaN(transX1)
                            || Double.isNaN(transY1)) {
                        return;
                    }

                    // Only draw line if it is more than a pixel away from the previous one
                    if (transX1 - transX0 > 2 || transX1 - transX0 < -2 || transY1 - transY0 > 2
                            || transY1 - transY0 < -2 || 0 == previousDrawnItem) {
                        previousDrawnItem = 1;

                        if (orientation == PlotOrientation.HORIZONTAL) {
                            state.workingLine.setLine(transY0, transX0, transY1, transX1);
                        } else if (orientation == PlotOrientation.VERTICAL) {
                            state.workingLine.setLine(transX0, transY0, transX1, transY1);
                        }

                        if (state.workingLine.intersects(dataArea)) {
                            g2.draw(state.workingLine);
                        }
                    } else {
                        // Increase counter for the previous drawn item.
                        previousDrawnItem++;
                        bAddEntity = false;
                    }
                }
            }
        }
    }

    if (getBaseShapesVisible()) {

        Shape shape = getItemShape(series, item);
        if (orientation == PlotOrientation.HORIZONTAL) {
            shape = ShapeUtilities.createTranslatedShape(shape, transY1, transX1);
        } else if (orientation == PlotOrientation.VERTICAL) {
            shape = ShapeUtilities.createTranslatedShape(shape, transX1, transY1);
        }
        if (shape.intersects(dataArea)) {
            bAddEntity = true;
            if (getItemShapeFilled(series, item)) {
                g2.fill(shape);
            } else {
                g2.draw(shape);
            }
        }
        entityArea = shape;

    }

    if (getPlotImages()) {
        final Image image = getImage(plot, series, item, transX1, transY1);
        if (image != null) {
            final Point hotspot = getImageHotspot(plot, series, item, transX1, transY1, image);
            g2.drawImage(image, (int) (transX1 - hotspot.getX()), (int) (transY1 - hotspot.getY()), null);
            entityArea = new Rectangle2D.Double(transX1 - hotspot.getX(), transY1 - hotspot.getY(),
                    image.getWidth(null), image.getHeight(null));
        }

    }

    // draw the item label if there is one...
    if (isItemLabelVisible(series, item)) {
        double xx = transX1;
        double yy = transY1;
        if (orientation == PlotOrientation.HORIZONTAL) {
            xx = transY1;
            yy = transX1;
        }
        drawItemLabel(g2, orientation, dataset, series, item, xx, yy, y1 < 0.0);
    }

    updateCrosshairValues(crosshairState, x1, y1, transX1, transY1, orientation);

    // add an entity for the item...
    if (entities != null && bAddEntity) {
        addEntity(entities, entityArea, dataset, series, item, transX1, transY1);
    }
}

From source file:gda.plots.SimpleXYItemRenderer.java

/**
 * Draws the visual representation of a single data item. This mostly reproduces the code of StandardXYItemRenderer
 * but using the line by line information stored in the SimpleXYSeries instead of the series indexed information
 * stored in the Renderer itself./*  w w  w.ja  va2 s. com*/
 * 
 * @param g2
 *            the graphics device.
 * @param state
 *            the renderer state.
 * @param dataArea
 *            the area within which the data is being drawn.
 * @param info
 *            collects information about the drawing.
 * @param plot
 *            the plot (can be used to obtain standard color information etc).
 * @param domainAxis
 *            the domain axis.
 * @param rangeAxis
 *            the range axis.
 * @param dataset
 *            the dataset.
 * @param series
 *            the series index (zero-based).
 * @param item
 *            the item index (zero-based).
 * @param crosshairState
 *            crosshair information for the plot ( <code>null</code> permitted).
 * @param pass
 *            the pass index.
 */
@Override
public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info,
        XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item,
        CrosshairState crosshairState, int pass) {
    SimpleXYSeries sxys = (SimpleXYSeries) ((SimpleXYSeriesCollection) dataset).getSeries(series);

    if (!sxys.isVisible()) {
        return;
    }
    // setup for collecting optional entity info...
    Shape entityArea = null;
    EntityCollection entities = null;
    if (info != null) {
        entities = info.getOwner().getEntityCollection();
    }

    PlotOrientation orientation = plot.getOrientation();
    g2.setPaint(sxys.getPaint());
    g2.setStroke(sxys.getStroke());

    // get the data point
    double x1 = dataset.getXValue(series, item);
    double y1 = dataset.getYValue(series, item);

    // Test
    x1 = xValueTransformer.transformValue(x1);

    if (Double.isNaN(x1) || Double.isNaN(y1)) {
        return;
    }

    RectangleEdge xAxisLocation = plot.getDomainAxisEdge();
    RectangleEdge yAxisLocation = plot.getRangeAxisEdge();
    double transX1 = domainAxis.valueToJava2D(x1, dataArea, xAxisLocation);
    double transY1 = rangeAxis.valueToJava2D(y1, dataArea, yAxisLocation);

    if (sxys.isDrawLines()) {
        if (item > 0) {
            // get the previous data point...
            double x0 = dataset.getXValue(series, item - 1);
            double y0 = dataset.getYValue(series, item - 1);

            // Test
            // System.out.print("tranformed " + x0);
            x0 = xValueTransformer.transformValue(x0);
            // Message.debug(" to " + x0);
            if (!Double.isNaN(x0) && !Double.isNaN(y0)) {
                boolean drawLine = true;
                if (getPlotDiscontinuous()) {
                    // only draw a line if the gap between the current and
                    // previous data
                    // point is within the threshold
                    int numX = dataset.getItemCount(series);
                    double minX = dataset.getXValue(series, 0);
                    double maxX = dataset.getXValue(series, numX - 1);
                    drawLine = (x1 - x0) <= ((maxX - minX) / numX * getGapThreshold());
                }
                if (drawLine) {
                    double transX0 = domainAxis.valueToJava2D(x0, dataArea, xAxisLocation);
                    double transY0 = rangeAxis.valueToJava2D(y0, dataArea, yAxisLocation);

                    // only draw if we have good values
                    if (Double.isNaN(transX0) || Double.isNaN(transY0) || Double.isNaN(transX1)
                            || Double.isNaN(transY1)) {
                        return;
                    }

                    if (orientation == PlotOrientation.HORIZONTAL) {
                        state.workingLine.setLine(transY0, transX0, transY1, transX1);
                    } else if (orientation == PlotOrientation.VERTICAL) {
                        state.workingLine.setLine(transX0, transY0, transX1, transY1);
                    }

                    if (state.workingLine.intersects(dataArea)) {
                        g2.draw(state.workingLine);
                    }
                }
            }
        }
    }

    if (sxys.isDrawMarkers()) {

        Shape shape = sxys.getSymbol();
        if (orientation == PlotOrientation.HORIZONTAL) {
            shape = ShapeUtilities.createTranslatedShape(shape, transY1, transX1);
        } else if (orientation == PlotOrientation.VERTICAL) {
            shape = ShapeUtilities.createTranslatedShape(shape, transX1, transY1);
        }
        if (shape.intersects(dataArea)) {
            g2.setPaint(sxys.getSymbolPaint());
            // Always use full stroke for drawing marker
            g2.setStroke(new BasicStroke());
            if (sxys.getFilled()) {
                g2.fill(shape);
            } else {
                g2.draw(shape);
            }
            g2.setPaint(sxys.getPaint());
            g2.setStroke(sxys.getStroke());
        }
        entityArea = shape;

    }

    if (getPlotImages()) {
        // use shape scale with transform??
        // double scale = getShapeScale(plot, series, item, transX1,
        // transY1);
        Image image = getImage(plot, series, item, transX1, transY1);
        if (image != null) {
            Point hotspot = getImageHotspot(plot, series, item, transX1, transY1, image);
            g2.drawImage(image, (int) (transX1 - hotspot.getX()), (int) (transY1 - hotspot.getY()), null);
            entityArea = new Rectangle2D.Double(transX1 - hotspot.getX(), transY1 - hotspot.getY(),
                    image.getWidth(null), image.getHeight(null));
        }

    }

    // draw the item label if there is one...
    if (isItemLabelVisible(series, item)) {
        drawItemLabel(g2, orientation, dataset, series, item, transX1, transY1, (y1 < 0.0));
    }

    updateCrosshairValues(crosshairState, x1, y1, transX1, transY1, orientation);

    // add an entity for the item...
    if (entities != null) {
        addEntity(entities, entityArea, dataset, series, item, transX1, transY1);
    }

}

From source file:uk.ac.babraham.BamQC.Graphs.ScatterGraph.java

public void showToolTip(int index, Point p) {
    if (GraphicsEnvironment.isHeadless()) {
        return;/*from  w  w  w  .  jav  a  2  s . com*/
    }
    p.setLocation(p.getX() + 10, p.getY() + 25);
    label.setText(tips.get(index));
    toolTip.pack();
    toolTip.setLocation(p);
    toolTip.setVisible(true);
}

From source file:edu.ku.brc.specify.tasks.subpane.wb.EditFormControlDlg.java

/**
 * Fills in the initial values./*w ww. ja va 2  s . c  o m*/
 */
protected void fill() {
    if (xCoord == null) {
        createUI();
    }

    Point location = inputPanel.getLocation();
    xCoord.setValue(((Double) location.getX()).intValue());
    yCoord.setValue(((Double) location.getY()).intValue());
    labelTF.setText(StringUtils.strip(inputPanel.getLabelText(), ":"));

    origLabel = inputPanel.getLabelText();
    origLocation = new Point(location.x, location.y);

    if (isTextField) {
        if (textFieldType != null) {
            fieldTypeIndex = inputPanel.getComp() instanceof JTextField ? 0 : 1;
            textFieldType.setSelectedIndex(fieldTypeIndex);
        }

        if (fieldWidth != null) {
            int cols = inputPanel.getComp() instanceof JTextField
                    ? ((JTextField) inputPanel.getComp()).getColumns()
                    : ((JTextArea) inputPanel.getComp()).getColumns();
            fieldWidth.setValue(cols);
        }

        if (numRows != null) {
            adjustTextRowsUI();
            int rows = inputPanel.getComp() instanceof JTextArea ? ((JTextArea) inputPanel.getComp()).getRows()
                    : 1;
            numRows.setValue(rows);
        }
    }
    changeTracker.clear();
}

From source file:edu.purdue.cc.bionet.ui.HeatMap.java

/**
 * Translates a set of coordinates into it's respective Correlation.
 * //from  w  w  w.j  a  va  2  s.  c  om
 * @param p The point on the graph to translate.
 * @return The Correlation corresponding to that point.
 */
private Correlation getCorrelationFromPoint(Point p) {
    int xComponent = (int) ((p.getX() - mapPosition.getX()) * moleculeList.size() / mapPosition.getWidth());
    int yComponent = moleculeList.size() - 1
            - (int) ((p.getY() - mapPosition.getY()) * moleculeList.size() / mapPosition.getHeight());
    return this.correlations.getCorrelation(moleculeList.get(xComponent), moleculeList.get(yComponent));

}

From source file:ijfx.core.overlay.OverlayStatService.java

public boolean areColinear(Point pt1, Point pt2, Point pt3) {

    boolean colinear = false;

    double signedArea = ((pt2.getX() - pt1.getX()) * (pt3.getY() - pt1.getY()))
            - ((pt3.getX() - pt1.getX()) * (pt2.getY() - pt1.getY()));

    colinear = (signedArea == 0.0);/*from   ww  w . ja  va2  s .c o m*/

    return colinear;
}

From source file:robots.ScrapBot.java

public void scrapWeapons(boolean verbose, boolean pretend) throws Exception {
    // TODO: Pretty sure I'll need to ensure that it's scrapping scrappable weapons.  eg. pull out genuines, etc.
    getSchema();//w  ww  . j  a  v  a2s.c om
    getBackpack();

    final Point smeltWeapons = pointProvider.getPoint(PointPlace.smeltWeapons);

    outputter.output("Scrapping Weapons...");
    leftClick(smeltWeapons.x, smeltWeapons.y);

    // Populate the array with all items and the information we care about.
    int bitmask = 0xFFFF;
    for (int i = 0; i < backpackItems.length(); i++) {
        JSONObject item = backpackItems.getJSONObject(i);
        int inventoryValue = backpackItems.getJSONObject(i).getInt("inventory");
        Weapon currentItem = new Weapon();
        currentItem.setDefindex(item.getInt("defindex"));
        currentItem.setInventorySlot(inventoryValue & bitmask);
        items.add(currentItem);
    }

    // Fill in remaining information and remove non-weapons
    ArrayList<Weapon> newList = new ArrayList<Weapon>();
    for (Weapon item : items) {
        for (int i = 0; i < schemaItems.length(); i++) {
            JSONObject schemaItem = schemaItems.getJSONObject(i);
            if (item.getDefindex().equals(schemaItem.getInt("defindex")) && item.getInventorySlot() > 0) {
                if (schemaItem.has("craft_material_type")) {
                    if (schemaItem.getString("craft_material_type").equals("weapon")) {
                        item.setName(schemaItem.getString("item_name"));
                        JSONArray classesJson = schemaItem.getJSONObject("used_by_classes")
                                .getJSONArray("class");
                        ArrayList<TF2Class> classes = new ArrayList<TF2Class>();
                        for (int j = 0; j < classesJson.length(); j++) {
                            String tf2Class = classesJson.getString(j);
                            TF2Class currentClass = TF2Class.SCOUT;
                            if (tf2Class.equals("Scout"))
                                currentClass = TF2Class.SCOUT;
                            else if (tf2Class.equals("Soldier"))
                                currentClass = TF2Class.SOLIDER;
                            else if (tf2Class.equals("Pyro"))
                                currentClass = TF2Class.PYRO;
                            else if (tf2Class.equals("Demoman"))
                                currentClass = TF2Class.DEMOMAN;
                            else if (tf2Class.equals("Heavy"))
                                currentClass = TF2Class.HEAVY;
                            else if (tf2Class.equals("Engineer"))
                                currentClass = TF2Class.ENGINEER;
                            else if (tf2Class.equals("Medic"))
                                currentClass = TF2Class.MEDIC;
                            else if (tf2Class.equals("Sniper"))
                                currentClass = TF2Class.SNIPER;
                            else if (tf2Class.equals("Spy"))
                                currentClass = TF2Class.SPY;
                            classes.add(currentClass);
                        }
                        item.setClasses(classes);
                        newList.add(item);
                    }
                }
            }
        }
    }
    items = newList;

    // Now, compare and determine two items to scrap
    ArrayList<Weapon> itemsToIgnore = new ArrayList<Weapon>();
    for (Weapon item : items) {
        // If the item is still there, it hasn't been used in crafting OR it hasn't been iterated to yet.
        if (!itemsToIgnore.contains(item)) {
            Weapon match = null;
            for (Weapon hopefulMatch : items) {
                if (!hopefulMatch.equals(item) && !itemsToIgnore.contains(hopefulMatch)) {
                    for (TF2Class tf2Class : item.getClasses()) {
                        for (TF2Class hopefulClass : hopefulMatch.getClasses()) {
                            if (tf2Class.equals(hopefulClass)) {
                                // These two weapons are compatible.  Scrap 'em!
                                match = hopefulMatch;
                                break;
                            }
                        }
                        if (match != null)
                            break;
                    }
                }
                if (match != null)
                    break;
            }
            // Come out here
            if (match != null) {
                // Scrap
                if (verbose)
                    outputter.output("Scrapping a " + item.getName() + " and a " + match.getName() + ".");
                if (!pretend) {
                    scrapWeapons(item, match);
                    Point mouseLoc = MouseInfo.getPointerInfo().getLocation();
                    Point ok2 = pointProvider.getPoint(PointPlace.ok2);
                    if (mouseLoc.getX() != ok2.x || mouseLoc.getY() != ok2.getY())
                        break;
                }
                itemsToIgnore.add(match);
            }
            itemsToIgnore.add(item);
        }
    }
    outputter.output("Weapons Scrapped.");
}

From source file:mobac.gui.components.JMapSourceTree.java

/**
 * Check if the mouse cursor was over a clickable node
 * /*w w  w.ja v  a 2s.  co  m*/
 * @param eventPoint
 *            - a mouse position coordinates
 * @return true if a node was clickable, false otherwise
 */
public boolean isLocationClickable(Point eventPoint) {
    int x = (int) eventPoint.getX();
    int y = (int) eventPoint.getY();
    TreePath treePathForXY = getPathForLocation(x, y);

    // If a node is an ancestor of a currently selected node - it can't be closed, so it is unclickable.
    if (treePathForXY != null && treePathForXY.isDescendant(findTreePathOfMapSource(selectedMapSource))) {
        return false;
    }

    boolean isInside = false;
    if (treePathForXY != null) {
        Rectangle pathBounds = this.getPathBounds(treePathForXY);
        isInside = pathBounds.contains(eventPoint);
    }
    return isInside;
}

From source file:org.rdv.viz.chart.FastXYItemRenderer.java

@Override
public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info,
        XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item,
        CrosshairState crosshairState, int pass) {

    boolean itemVisible = getItemVisible(series, item);

    // setup for collecting optional entity info...
    Shape entityArea = null;//from  w w  w  . j a v a2s  . com
    EntityCollection entities = null;
    if (info != null) {
        entities = info.getOwner().getEntityCollection();
    }

    PlotOrientation orientation = plot.getOrientation();
    Paint paint = getItemPaint(series, item);
    Stroke seriesStroke = getItemStroke(series, item);
    g2.setPaint(paint);
    g2.setStroke(seriesStroke);

    // get the data point...
    double x1 = dataset.getXValue(series, item);
    double y1 = dataset.getYValue(series, item);
    if (Double.isNaN(x1) || Double.isNaN(y1)) {
        itemVisible = false;
    }

    RectangleEdge xAxisLocation = plot.getDomainAxisEdge();
    RectangleEdge yAxisLocation = plot.getRangeAxisEdge();
    double transX1 = domainAxis.valueToJava2D(x1, dataArea, xAxisLocation);
    double transY1 = rangeAxis.valueToJava2D(y1, dataArea, yAxisLocation);

    if (getPlotLines()) {
        if (item == 0) {
            previousDrawnItem = 1;
        }

        if (getDrawSeriesLineAsPath()) {
            State s = (State) state;
            if (s.getSeriesIndex() != series) {
                // we are starting a new series path
                s.seriesPath.reset();
                s.setLastPointGood(false);
                s.setSeriesIndex(series);
            }

            // update path to reflect latest point
            if (itemVisible && !Double.isNaN(transX1) && !Double.isNaN(transY1)) {
                float x = (float) transX1;
                float y = (float) transY1;
                if (orientation == PlotOrientation.HORIZONTAL) {
                    x = (float) transY1;
                    y = (float) transX1;
                }
                if (s.isLastPointGood()) {
                    // TODO: check threshold
                    s.seriesPath.lineTo(x, y);
                } else {
                    s.seriesPath.moveTo(x, y);
                }
                s.setLastPointGood(true);
            } else {
                s.setLastPointGood(false);
            }
            if (item == dataset.getItemCount(series) - 1) {
                if (s.getSeriesIndex() == series) {
                    // draw path
                    g2.setStroke(lookupSeriesStroke(series));
                    g2.setPaint(lookupSeriesPaint(series));
                    g2.draw(s.seriesPath);
                }
            }
        }

        else if (item != 0 && itemVisible) {
            // get the previous data point...
            double x0 = dataset.getXValue(series, item - previousDrawnItem);
            double y0 = dataset.getYValue(series, item - previousDrawnItem);
            if (!Double.isNaN(x0) && !Double.isNaN(y0)) {
                boolean drawLine = true;
                if (getPlotDiscontinuous()) {
                    // only draw a line if the gap between the current and
                    // previous data point is within the threshold
                    int numX = dataset.getItemCount(series);
                    double minX = dataset.getXValue(series, 0);
                    double maxX = dataset.getXValue(series, numX - 1);
                    if (getGapThresholdType() == UnitType.ABSOLUTE) {
                        drawLine = Math.abs(x1 - x0) <= getGapThreshold();
                    } else {
                        drawLine = Math.abs(x1 - x0) <= ((maxX - minX) / numX * getGapThreshold());
                    }
                }
                if (drawLine) {
                    double transX0 = domainAxis.valueToJava2D(x0, dataArea, xAxisLocation);
                    double transY0 = rangeAxis.valueToJava2D(y0, dataArea, yAxisLocation);

                    // only draw if we have good values
                    if (Double.isNaN(transX0) || Double.isNaN(transY0) || Double.isNaN(transX1)
                            || Double.isNaN(transY1)) {
                        return;
                    }

                    // Only draw line if it is more than a pixel away from the
                    // previous one
                    if ((transX1 - transX0 > 2 || transX1 - transX0 < -2 || transY1 - transY0 > 2
                            || transY1 - transY0 < -2)) {
                        previousDrawnItem = 1;

                        if (orientation == PlotOrientation.HORIZONTAL) {
                            state.workingLine.setLine(transY0, transX0, transY1, transX1);
                        } else if (orientation == PlotOrientation.VERTICAL) {
                            state.workingLine.setLine(transX0, transY0, transX1, transY1);
                        }

                        if (state.workingLine.intersects(dataArea)) {
                            g2.draw(state.workingLine);
                        }
                    } else {
                        // Increase counter for the previous drawn item.
                        previousDrawnItem++;
                    }
                }
            }
        }
    }

    // we needed to get this far even for invisible items, to ensure that
    // seriesPath updates happened, but now there is nothing more we need
    // to do for non-visible items...
    if (!itemVisible) {
        return;
    }

    // add a cursor to indicate the position of the last data item
    if (getCursorVisible() && item == dataset.getItemCount(series) - 1) {
        Line2D cursorX = new Line2D.Double(transX1 - DEFAULT_CURSOR_SIZE, transY1,
                transX1 + DEFAULT_CURSOR_SIZE, transY1);
        g2.draw(cursorX);
        Line2D cursorY = new Line2D.Double(transX1, transY1 - DEFAULT_CURSOR_SIZE, transX1,
                transY1 + DEFAULT_CURSOR_SIZE);
        g2.draw(cursorY);
    }

    if (getBaseShapesVisible()) {

        Shape shape = getItemShape(series, item);
        if (orientation == PlotOrientation.HORIZONTAL) {
            shape = ShapeUtilities.createTranslatedShape(shape, transY1, transX1);
        } else if (orientation == PlotOrientation.VERTICAL) {
            shape = ShapeUtilities.createTranslatedShape(shape, transX1, transY1);
        }
        if (shape.intersects(dataArea)) {
            if (getItemShapeFilled(series, item)) {
                g2.fill(shape);
            } else {
                g2.draw(shape);
            }
        }
        entityArea = shape;

    }

    if (getPlotImages()) {
        Image image = getImage(plot, series, item, transX1, transY1);
        if (image != null) {
            Point hotspot = getImageHotspot(plot, series, item, transX1, transY1, image);
            g2.drawImage(image, (int) (transX1 - hotspot.getX()), (int) (transY1 - hotspot.getY()), null);
            entityArea = new Rectangle2D.Double(transX1 - hotspot.getX(), transY1 - hotspot.getY(),
                    image.getWidth(null), image.getHeight(null));
        }

    }

    double xx = transX1;
    double yy = transY1;
    if (orientation == PlotOrientation.HORIZONTAL) {
        xx = transY1;
        yy = transX1;
    }

    // draw the item label if there is one...
    if (isItemLabelVisible(series, item)) {
        drawItemLabel(g2, orientation, dataset, series, item, xx, yy, (y1 < 0.0));
    }

    int domainAxisIndex = plot.getDomainAxisIndex(domainAxis);
    int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis);
    updateCrosshairValues(crosshairState, x1, y1, domainAxisIndex, rangeAxisIndex, transX1, transY1,
            orientation);

    // add an entity for the item...
    if (entities != null && dataArea.contains(xx, yy)) {
        addEntity(entities, entityArea, dataset, series, item, xx, yy);
    }
}

From source file:net.lmxm.ute.preferences.AbstractPreferences.java

/**
 * Sets the point.//from   w ww . j a v  a  2  s .  c om
 * 
 * @param key the key
 * @param point the point
 */
protected final void setPoint(final String key, final Point point) {
    final String prefix = "setPoint() :";

    LOGGER.debug("{} entered, key={}", prefix, key);

    if (point == null) {
        LOGGER.debug("{} point is null, returning without setting", prefix);

        return;
    }

    setInt(key + X_SUFFIX, (int) point.getX());
    setInt(key + Y_SUFFIX, (int) point.getY());

    LOGGER.debug("{} leaving", prefix);
}