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:com.bdb.weather.display.day.ItemRenderer.java

/**
 * Plots the data for a given series./*w ww .  ja  v  a 2s .co  m*/
 * 
 * @param g2  the drawing surface.
 * @param dataArea  the data area.
 * @param info  collects plot rendering info.
 * @param plot  the plot.
 * @param dataset  the dataset.
 * @param seriesIndex  the series index.
 */
@Override
public void drawSeries(Graphics2D g2, Rectangle2D dataArea, PlotRenderingInfo info, PolarPlot plot,
        XYDataset dataset, int seriesIndex) {
    Shape point = new Rectangle2D.Double(-2, -2, 4, 4);

    int numPoints = dataset.getItemCount(seriesIndex);

    g2.setPaint(lookupSeriesPaint(seriesIndex));
    g2.setStroke(lookupSeriesStroke(seriesIndex));

    for (int i = 0; i < numPoints; i++) {
        double theta = dataset.getXValue(seriesIndex, i);
        double radius = dataset.getYValue(seriesIndex, i);

        Point p = plot.translateToJava2D(theta, radius, plot.getAxis(), dataArea);

        Shape shape = ShapeUtilities.createTranslatedShape(point, p.getX(), p.getY());

        g2.fill(shape);
    }
}

From source file:org.cytoscape.ding.impl.cyannotator.dialogs.LoadImageDialog.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    try {/*from w ww .  j  av a2  s.co  m*/
        //Read the selected Image, create an Image Annotation, repaint the whole network and then dispose off this Frame
        File imageFile = jFileChooser1.getSelectedFile(); // Get the file
        BufferedImage image = ImageIO.read(imageFile);
        URL url = imageFile.toURI().toURL();
        //The Attributes are x, y, Image, componentNumber, scaleFactor
        ImageAnnotationImpl newOne = new ImageAnnotationImpl(cyAnnotator, view, (int) startingLocation.getX(),
                (int) startingLocation.getY(), url, image, view.getZoom(), cgm);

        newOne.addComponent(null);
        cyAnnotator.addAnnotation(newOne);
        newOne.getCanvas().repaint();

        // Set this shape to be resized
        cyAnnotator.resizeShape(newOne);

        try {
            // Warp the mouse to the starting location (if supported)
            Point start = newOne.getComponent().getLocationOnScreen();
            Robot robot = new Robot();
            robot.mouseMove((int) start.getX() + 100, (int) start.getY() + 100);
        } catch (Exception e) {
        }

        this.dispose();
    } catch (Exception ex) {
        logger.warn("Unable to load the selected image", ex);
    }
}

From source file:org.kalypso.ogc.gml.widgets.base.PanToWidget.java

@Override
public void mouseDragged(final MouseEvent e) {
    final IMapPanel mapPanel = getMapPanel();
    if (mapPanel == null)
        return;/*from w  ww. ja v a  2 s . co  m*/

    final Point point = e.getPoint();

    if (m_world2screen != null && m_startPoint != null) {
        final GM_Position pixelPos = GeometryFactory.createGM_Position(point.getX(), point.getY());
        m_endPoint = m_world2screen.getSourcePoint(pixelPos);

        final GM_Envelope panExtent = calcPanExtent();
        mapPanel.setBoundingBox(panExtent, false, false);
    }
}

From source file:org.kalypso.ogc.gml.widgets.base.PanToWidget.java

@Override
public void mousePressed(final MouseEvent e) {
    if (!ArrayUtils.contains(m_mouseButtons, e.getButton()))
        return;/*from  w w  w.j a  v a2s. co  m*/

    final IMapPanel mapPanel = getMapPanel();
    if (mapPanel == null)
        return;

    final Point point = e.getPoint();

    m_world2screen = mapPanel.getProjection();
    if (m_world2screen == null)
        return;

    final GM_Position pixelPos = GeometryFactory.createGM_Position(point.getX(), point.getY());
    m_startPoint = m_world2screen.getSourcePoint(pixelPos);

    m_endPoint = null;
}

From source file:net.sf.jasperreports.customizers.shape.AbstractShapeCustomizer.java

/**
 * Builds an ellipse shape.//from  ww w .  j a v a2s .co  m
 * 
 * @return the ellipse or null if its size is not specified
 */
protected Shape buildEllipse() {
    Ellipse2D ellipse = null;
    Dimension2D size = getSize();
    if (size != null) {
        Point offset = getOffset(size);
        ellipse = new Ellipse2D.Float(-offset.getX(), -offset.getY(), (float) size.getWidth(),
                (float) size.getHeight());
    }
    return ellipse;
}

From source file:net.sf.jasperreports.customizers.shape.AbstractShapeCustomizer.java

/**
 * Builds a rectangle shape.//www. j  a v  a  2 s .  c  o m
 * 
 * @return the rectangle or null if its size is not specified
 */
protected Shape buildRectangle() {
    Rectangle2D rectangle = null;
    Dimension2D size = getSize();
    if (size != null) {
        Point offset = getOffset(size);
        rectangle = new Rectangle2D.Float(-offset.getX(), -offset.getY(), (float) size.getWidth(),
                (float) size.getHeight());
    }
    return rectangle;
}

From source file:net.sf.jasperreports.customizers.shape.AbstractShapeCustomizer.java

/**
 * Uses the points to build a polyline//w  w w  .  j a  v a2s .  c o  m
 * 
 * @param baseShape the points of the polyline
 * @return a polyline shape or null if it can't be build from the current configuration
 */
protected Shape buildPolyline(ShapePoints baseShape) {
    Path2D path = null;
    List<Point> points = baseShape.getPoints();
    if (points != null && !points.isEmpty()) {
        float scaleFactorX = 1.0f;
        float scaleFactorY = 1.0f;

        Rectangle2D bounds = getBounds(baseShape);
        Integer width = getWidth();
        Integer height = getHeight();
        if (width != null) {
            scaleFactorX = (float) (width / bounds.getWidth());
        }
        if (height != null) {
            scaleFactorY = (float) (height / bounds.getHeight());
        }

        path = new Path2D.Double();

        if (points.size() > 1) {
            Point offset = getOffset(bounds);
            Point point = points.get(0);

            path.moveTo((point.getX() - offset.getX()) * scaleFactorX,
                    (point.getY() - offset.getY()) * scaleFactorY);
            for (int i = 1; i < points.size(); i++) {
                point = points.get(i);
                path.lineTo((point.getX() - offset.getX()) * scaleFactorX,
                        (point.getY() - offset.getY()) * scaleFactorY);
            }
        }
    }
    return path;
}

From source file:net.sf.jasperreports.customizers.shape.AbstractShapeCustomizer.java

/**
 * Builds a polygon shape.//  w w  w  .  j a  v  a2 s  . c om
 * 
 * @param shapePoints the points of the polygon
 * @return the polygon or null if it can't be build from the current configuration
 */
protected Shape buildPolygon(ShapePoints shapePoints) {
    Polygon polygon = null;
    List<Point> points = shapePoints.getPoints();
    if (points != null && !points.isEmpty()) {
        float scaleFactorX = 1.0f;
        float scaleFactorY = 1.0f;

        Rectangle2D bounds = getBounds(shapePoints);
        Integer width = getWidth();
        Integer height = getHeight();
        if (width != null) {
            scaleFactorX = (float) width / (float) bounds.getWidth();
        }
        if (height != null) {
            scaleFactorY = (float) height / (float) bounds.getHeight();
        }

        Point offset = getOffset(bounds);

        int[] pointsX = new int[points.size()];
        int[] pointsY = new int[points.size()];

        for (int i = 0; i < points.size(); i++) {
            Point point = points.get(i);
            pointsX[i] = Math.round((point.getX() - offset.getX()) * scaleFactorX);
            pointsY[i] = Math.round((point.getY() - offset.getY()) * scaleFactorY);
        }

        polygon = new Polygon(pointsX, pointsY, points.size());
    }
    return polygon;
}

From source file:mulavito.gui.control.AbstractPopupMousePlugin.java

/**
 * Reduced functionality of super class method and extended by own
 * content-aware editing.//w ww  .  ja  va  2 s  .  c  o  m
 */
@SuppressWarnings("unchecked")
@Override
protected final void handlePopup(final MouseEvent e) {
    if (checkModifiers(e)) {
        final LV vv = (LV) e.getSource();
        final Layout<V, E> layout = vv.getGraphLayout();
        final L graph = (L) layout.getGraph();
        final Point p = e.getPoint();

        final List<V> sel_vertices = getSelectedVertices();
        final List<E> sel_edges = getSelectedEdges();

        GraphElementAccessor<V, E> pickSupport = vv.getPickSupport();
        if (pickSupport != null) {
            V vertex = pickSupport.getVertex(layout, p.getX(), p.getY());
            E edge = pickSupport.getEdge(layout, p.getX(), p.getY());

            if (vertex != null && !sel_vertices.contains(vertex))
                sel_vertices.add(vertex);
            if (edge != null && !sel_edges.contains(edge))
                sel_edges.add(edge);
        }

        popup.removeAll();
        if (sel_vertices.size() > 0)
            createVertexMenuEntries(p, graph, vv, sel_vertices);
        else if (sel_edges.size() > 0)
            createEdgeMenuEntries(p, graph, vv, sel_edges);
        else
            createGeneralMenuEntries(p, graph, vv);

        if (popup.getComponentCount() > 0)
            popup.show(vv, e.getX(), e.getY());
    }
}

From source file:org.kalypso.ogc.gml.widgets.WidgetManager.java

protected boolean isInsideMapFrame(final Point p) {
    // FIXME: at least comment: where does this THRESHOLD come from?
    final int THRESHOLD = 35; // pixel

    if (p.getX() < THRESHOLD || p.getX() > m_mapPanel.getWidth() - THRESHOLD || p.getY() < THRESHOLD
            || p.getY() > m_mapPanel.getHeight() - THRESHOLD)
        return false;

    return true;/* w w w.j  av a 2 s .c  o m*/
}