Example usage for java.awt Point Point

List of usage examples for java.awt Point Point

Introduction

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

Prototype

public Point(int x, int y) 

Source Link

Document

Constructs and initializes a point at the specified (x,y) location in the coordinate space.

Usage

From source file:knop.psfj.FovDataSet.java

/**
 * Export to crappy format.// ww w  .  j  a v a  2 s  .  c om
 * 
 * @param path
 *           the path
 */
public void exportToCrappyFormat(String path) {

    StringBuffer buffer = new StringBuffer(10000);
    buffer.append("Index\txSource\tySource\txTarget\tyTarget\n");

    Vector<Point> sourceList = new Vector<Point>();
    Vector<Point> targetList = new Vector<Point>();

    for (int i = 0; i != getColumnSize(); i++) {
        int xSource = MathUtils.round(getDoubleValue("xSource", i));
        int ySource = MathUtils.round(getDoubleValue("ySource", i));
        int xTarget = MathUtils.round(getDoubleValue("xTarget", i));
        int yTarget = MathUtils.round(getDoubleValue("yTarget", i));

        Point source = new Point(xSource, ySource);
        Point target = new Point(xTarget, yTarget);

        sourceList.add(source);
        targetList.add(target);

    }
    savePoints(sourceList, targetList, path);
}

From source file:de._13ducks.cor.graphics.GraphicsComponent.java

public void setCursor(boolean rcursor) {
    renderCursor = rcursor;//from w  ww  . j  a  va 2  s. c o m
    if (rcursor) {
        int[] pixels = new int[16 * 16];
        Image image = Toolkit.getDefaultToolkit().createImage(new MemoryImageSource(16, 16, pixels, 0, 16));
        Cursor transparentCursor = Toolkit.getDefaultToolkit().createCustomCursor(image, new Point(0, 0),
                "invisibleCursor");
        this.setCursor(transparentCursor);
    } else {
        this.setCursor(Cursor.getDefaultCursor());
    }
}

From source file:canreg.client.gui.analysis.FrequenciesByYearInternalFrame.java

/**
 *
 * @param offset/*from w  w  w . java2 s .co  m*/
 * @param evt
 */
public void showPopUpMenu(int offset, java.awt.event.MouseEvent evt) {
    JTable target = (JTable) evt.getSource();
    int rowNumber = target.rowAtPoint(new Point(evt.getX(), evt.getY()));
    rowNumber = target.convertRowIndexToModel(rowNumber);

    JPopupMenu jpm = new JPopupMenu();
    jpm.add(java.util.ResourceBundle
            .getBundle("canreg/client/gui/analysis/resources/FrequenciesByYearInternalFrame")
            .getString("SHOW_IN_BROWSER"));
    TableModel tableModel = target.getModel();
    // resultTable.get
    // jpm.add("Column " + rowNumber +" " + tableColumnModel.getColumn(tableColumnModel.getColumnIndexAtX(evt.getX())).getHeaderValue());
    int year = Integer.parseInt((String) tableModel.getValueAt(rowNumber, 0));

    String filterString = "INCID >= '" + year * 10000 + "' AND INCID <'" + (year + 1) * 10000 + "'";

    for (DatabaseVariablesListElement dvle : chosenVariables) {
        int columnNumber = tableColumnModel
                .getColumnIndex(canreg.common.Tools.toUpperCaseStandardized(dvle.getDatabaseVariableName()));
        String value = tableModel.getValueAt(rowNumber, columnNumber).toString();
        filterString += " AND " + canreg.common.Tools.toUpperCaseStandardized(dvle.getDatabaseVariableName())
                + " = " + dvle.getSQLqueryFormat(value);
    }
    DatabaseFilter filter = new DatabaseFilter();
    filter.setFilterString(filterString);
    Logger.getLogger(FrequenciesByYearInternalFrame.class.getName()).log(Level.INFO, "FilterString: {0}",
            filterString);
    try {
        tableDatadescriptionPopUp = canreg.client.CanRegClientApp.getApplication()
                .getDistributedTableDescription(filter, rangeFilterPanel.getSelectedTable());
        Object[][] rows = canreg.client.CanRegClientApp.getApplication().retrieveRows(
                tableDatadescriptionPopUp.getResultSetID(), 0, MAX_ENTRIES_DISPLAYED_ON_RIGHT_CLICK);
        String[] variableNames = tableDatadescriptionPopUp.getColumnNames();
        for (Object[] row : rows) {
            String line = "";
            int i = 0;
            for (Object obj : row) {
                if (obj != null) {
                    line += variableNames[i] + ": " + obj.toString() + ", ";
                }
                i++;
            }
            jpm.add(line);
        }
    } catch (SQLException ex) {
        Logger.getLogger(FrequenciesByYearInternalFrame.class.getName()).log(Level.SEVERE, null, ex);
    } catch (RemoteException ex) {
        Logger.getLogger(FrequenciesByYearInternalFrame.class.getName()).log(Level.SEVERE, null, ex);
    } catch (SecurityException ex) {
        Logger.getLogger(FrequenciesByYearInternalFrame.class.getName()).log(Level.SEVERE, null, ex);
    } catch (DistributedTableDescriptionException ex) {
        Logger.getLogger(FrequenciesByYearInternalFrame.class.getName()).log(Level.SEVERE, null, ex);
    } catch (UnknownTableException ex) {
        Logger.getLogger(FrequenciesByYearInternalFrame.class.getName()).log(Level.SEVERE, null, ex);
    }

    int cases = (Integer) tableModel.getValueAt(rowNumber, tableColumnModel.getColumnIndex("CASES"));
    if (MAX_ENTRIES_DISPLAYED_ON_RIGHT_CLICK < cases) {
        jpm.add("...");
    }
    MenuItem menuItem = new MenuItem();

    jpm.show(target, evt.getX(), evt.getY());
}

From source file:biogenesis.Organism.java

/**
 * Tries to find a spare place in the world for this organism and place it.
 * It also generates an identification number for the organism if it can be placed
 * somewhere./*from ww w . j a  va2 s.  c  om*/
 * 
 * @return  true if a suitable place has been found, false if not.
 */
private boolean placeRandom() {
    /* We try to place the organism in 12 different positions. If all of them
     * are occupied, we return false.
     */
    for (int i = 12; i > 0; i--) {
        /* Get a random point for the top left corner of the organism
         * making sure it is inside the world.
         */
        Point origin = new Point(Utils.random.nextInt(_world.getWidth() - _sizeRect.width),
                Utils.random.nextInt(_world.getHeight() - _sizeRect.height));
        setBounds(origin.x, origin.y, _sizeRect.width, _sizeRect.height);
        _dCenterX = _centerX = origin.x + (_sizeRect.width >> 1);
        _dCenterY = _centerY = origin.y + (_sizeRect.height >> 1);
        // Check that the position is not occupied.
        if (_world.fastCheckHit(this) == null) {
            // Generate an identification
            _ID = _world.getNewId();
            return true;
        }
    }
    // If we get here, we haven't find a place for this organism.
    return false;
}

From source file:pipeline.parameter_cell_views.FloatRangeSlider.java

/**
 * Translates MouseEvent screen coordinates to coordinates in chart units
 * /* ww w. j  av  a 2  s .  com*/
 * @param e
 *            MouseEvent containing coordinates of interest
 * @return Chart coordinates (evaluated as double)
 */
private @Nullable Point2D getChartCoordinates(MouseEvent e) {
    if (chartPanel.getChartRenderingInfo().getChartArea().getHeight() == 0) {
        Utils.log("Cannot translate to chart coordinates", LogLevel.DEBUG);
        return null;
    }
    int mouseX = e.getX();
    int mouseY = e.getY();
    Utils.log("x = " + mouseX + ", y = " + mouseY, LogLevel.DEBUG);
    Point2D p = chartPanel.translateScreenToJava2D(new Point(mouseX, mouseY));
    XYPlot plot = (XYPlot) chart.getPlot();
    Rectangle2D plotArea = this.chartPanel.getChartRenderingInfo().getPlotInfo().getDataArea();
    ValueAxis domainAxis = plot.getDomainAxis();
    RectangleEdge domainAxisEdge = plot.getDomainAxisEdge();
    ValueAxis rangeAxis = plot.getRangeAxis();
    RectangleEdge rangeAxisEdge = plot.getRangeAxisEdge();
    double chartX = domainAxis.java2DToValue(p.getX(), plotArea, domainAxisEdge);
    double chartY = rangeAxis.java2DToValue(p.getY(), plotArea, rangeAxisEdge);
    return new Point2D.Double(chartX, chartY);
}

From source file:it.unibas.spicygui.controllo.provider.intermediatezone.WidgetCreator.java

public Widget createCompositionMergeWidget(Scene scene, LayerWidget mainLayer, LayerWidget connectionLayer,
        Point point, GraphSceneGlassPane glassPane) {
    MergeWidget rootWidget = new MergeWidget(scene, point);
    CaratteristicheWidgetMergeComposition caratteristicheWidget = new CaratteristicheWidgetMergeComposition();

    caratteristicheWidget.setTreeType(Costanti.COMPOSITION_TYPE);

    //        rootWidget.getActions().addAction(ActionFactory.createEditAction(new MyEditProviderFunction(caratteristicheWidget)));

    rootWidget.getActions().addAction(ActionFactory.createConnectAction(connectionLayer,
            new ActionMergeConnection(connectionLayer, mainLayer, caratteristicheWidget)));

    rootWidget.getActions().addAction(ActionFactory.createPopupMenuAction(
            new MyPopupProviderWidgetMergeComposition(glassPane.getScene(), connectionLayer)));
    //        rootWidget.getActions().addAction(ActionFactory.createMoveAction());

    CaratteristicheBarra caratteristicheBarra = new CaratteristicheBarra(rootWidget, Costanti.INTERMEDIE_BARRA);
    IconNodeWidget barra = new IconNodeWidget(scene);
    barra.setImage(ImageUtilities.loadImage(Costanti.ICONA_MOVE));
    Point pointBarra = new Point(rootWidget.getPreferredLocation().x - Costanti.OFF_SET_X_WIDGET_BARRA,
            rootWidget.getPreferredLocation().y - Costanti.OFF_SET_Y_WIDGET_BARRA);
    barra.setPreferredLocation(pointBarra);
    MyMoveProviderGeneric moveProvider = new MyMoveProviderGeneric();
    barra.getActions().addAction(ActionFactory.createMoveAction(moveProvider, moveProvider));
    caratteristicheWidget.setWidgetBarra(barra);

    mainLayer.addChild(rootWidget, caratteristicheWidget);
    mainLayer.addChild(barra, caratteristicheBarra);

    glassPane.addFunction(rootWidget);// www  . ja v  a 2 s. c  om
    glassPane.addFunction(barra);
    scene.validate();

    return rootWidget;
}

From source file:com.qumasoft.guitools.compare.CompareFrame.java

void positionViewPort(int index) {
    captureViewPortSize();//w  ww .  j  a  v  a 2  s.  c  om
    int midScreenRow = verticalLinesInViewPort / 2;
    int topRow;
    if ((file1ContentsListModel.size() - index) < midScreenRow) {
        // We're positioning near the end of the file, so there's no place to scroll down.
        // Just show the last full screen of lines.
        topRow = file1ContentsListModel.size() - verticalLinesInViewPort;
    } else {
        // We're able to scroll around.
        topRow = index - midScreenRow;
    }
    if (topRow < 0) {
        topRow = 0;
    }
    leftScrollPaneViewPort.setViewPosition(new Point(0, topRow * file1ContentsList.getRowHeight()));
}

From source file:com.android.hierarchyviewerlib.device.DeviceBridge.java

private static boolean readLayer(DataInputStream in, PsdFile psd) {
    try {//from  w  w  w  .j  av a  2s.  c  o  m
        if (in.read() == 2) {
            return false;
        }
        String name = in.readUTF();
        boolean visible = in.read() == 1;
        int x = in.readInt();
        int y = in.readInt();
        int dataSize = in.readInt();

        byte[] data = new byte[dataSize];
        int read = 0;
        while (read < dataSize) {
            read += in.read(data, read, dataSize - read);
        }

        ByteArrayInputStream arrayIn = new ByteArrayInputStream(data);
        BufferedImage chunk = ImageIO.read(arrayIn);

        // Ensure the image is in the right format
        BufferedImage image = new BufferedImage(chunk.getWidth(), chunk.getHeight(),
                BufferedImage.TYPE_INT_ARGB);
        Graphics2D g = image.createGraphics();
        g.drawImage(chunk, null, 0, 0);
        g.dispose();

        psd.addLayer(name, image, new Point(x, y), visible);

        return true;
    } catch (Exception e) {
        return false;
    }
}

From source file:ca.sqlpower.architect.swingui.TestPlayPen.java

/**
 * This tests that copying and pasting a table with source information into
 * the play pen works. This also confirms that the new table copied uses
 * the table reverse engineered from as its source.
 *///from w  w  w. j  a  va2s .c o  m
public void testPasteReverseEngineeredTable() throws Exception {
    SQLDatabase db = new SQLDatabase();
    pp.getSession().getRootObject().addChild(db);
    SQLColumn sourceCol = new SQLColumn();
    SQLTable sourceTable = new SQLTable(db, true);
    sourceTable.addColumn(sourceCol);
    SQLTable table = new SQLTable(db, "NewTable", "Remarks", "TABLE", true);
    final SQLColumn col1 = new SQLColumn(table, "NewCol1", Types.VARCHAR, 50, 0);
    col1.setSourceColumn(sourceCol);
    table.addColumn(col1);
    final SQLColumn col2 = new SQLColumn(table, "NewCol2", Types.NUMERIC, 50, 0);
    col2.setSourceColumn(sourceCol);
    table.addColumn(col2);

    DuplicateProperties duplicateProperties = ASUtils.createDuplicateProperties(pp.getSession(), table);
    pp.importTableCopy(table, new Point(0, 0), duplicateProperties);
    assertEquals(1, pp.getTables().size());
    SQLTable copy = pp.getTables().get(0);
    assertEquals("NewTable", copy.getName());
    assertEquals(2, copy.getColumns().size());
    assertTrue(copy.getColumnByName("NewCol1") != null);
    assertTrue(copy.getColumnByName("NewCol2") != null);
    assertEquals(col1, copy.getColumnByName("NewCol1").getSourceColumn());
    assertEquals(col2, copy.getColumnByName("NewCol2").getSourceColumn());
}

From source file:com.hexidec.ekit.component.RelativeImageView.java

/** Select or grow image when clicked.
  *//*ww w.j  av a 2s .  c o m*/
public void mousePressed(MouseEvent e) {
    Dimension size = fComponent.getSize();
    if ((e.getX() >= (size.width - 7)) && (e.getY() >= (size.height - 7)) && (getSelectionState() == 2)) {
        // Click in selected grow-box:
        Point loc = fComponent.getLocationOnScreen();
        fGrowBase = new Point(loc.x + e.getX() - fWidth, loc.y + e.getY() - fHeight);
        fGrowProportionally = e.isShiftDown();
    } else {
        // Else select image:
        fGrowBase = null;
        JTextComponent comp = (JTextComponent) fContainer;
        int start = fElement.getStartOffset();
        int end = fElement.getEndOffset();
        int mark = comp.getCaret().getMark();
        int dot = comp.getCaret().getDot();
        if (e.isShiftDown()) {
            // extend selection if shift key down:
            if (mark <= start) {
                comp.moveCaretPosition(end);
            } else {
                comp.moveCaretPosition(start);
            }
        } else {
            // just select image, without shift:
            if (mark != start) {
                comp.setCaretPosition(start);
            }
            if (dot != end) {
                comp.moveCaretPosition(end);
            }
        }
    }
}