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:com.diversityarrays.kdxplore.field.FieldViewDialog.java

private void doAutoAdvance() {
    Sample lastSample = null;/*w  w w  .j  a  va  2  s .  c  om*/
    Sample lastUnscoredSample = null;
    for (Sample sample : lastSelectedPlot) {
        lastSample = sample;
        if (!sample.hasBeenScored()) {
            lastUnscoredSample = sample;
        }
    }

    NextUnscoredSampleRowFinder finder = new NextUnscoredSampleRowFinder(fieldViewPanel.getPlotVisitList());
    UnscoredSampleSearchResult searchResult = finder.findNextScoreRequiredSample(lastSample, null);
    if (searchResult == null) {
        MsgBox.info(FieldViewDialog.this, "No next unscored", "Find Next Unscored");
    } else {
        XYPos xy = fieldViewPanel.getFieldLayoutTableModel().getXYForPlot(searchResult.sample.getPlotId());
        if (xy != null) {
            List<Point> points = Arrays.asList(new Point(xy.x, xy.y));
            fieldLayoutTable.setSelectedPoints(points);
            //               Plot plot = fieldViewPanel.getFieldLayoutTableModel().getPlot(xy.y, xy.x);
        }
    }

}

From source file:de.tor.tribes.ui.wiz.ret.RetimerCalculationPanel.java

private void scroll() {
    Point point = new Point(0, (int) (jTextPane1.getSize().getHeight()));
    JViewport vp = jScrollPane1.getViewport();
    if ((vp == null) || (point == null)) {
        return;/*from  w  ww .  ja va2  s .  c  o m*/
    }
    vp.setViewPosition(point);
}

From source file:com.xilinx.ultrascale.gui.MainScreen_video.java

public void configureScreen(int mode, LandingPage lp) {
    //        System.out.println("got in main screen configuration");
    this.lp = lp;
    screenMode = mode;//from w  w  w.ja  v a2 s  . co  m
    testStarted = false;
    if (Develop.production == 1) {
        di = null;
        di = new DriverInfo();
        if (mode == 2) {
            di.init(mode, 1);
        } else {
            di.init(mode, 2);
        }
        //            System.out.println("reading bar info");
        int ret = di.get_PCIstate();
        ret = di.getBarInfo();
        //            System.out.println("read bar info");
        // fill pcie data
        if (mode != 6) { //ie., not a control plane
            pciemodel = new MyTableModel(di.getPCIInfo().getPCIData(), pcieColumnNames);
            pcieSysmontable.setModel(pciemodel);

            hostCredits = new MyTableModel(di.getPCIInfo().getHostedData(), pcieColumnNames);
            hostsysmontable.setModel(hostCredits);
        } else {
            pciemodel = new MyTableModel(di.getPCIInfo().getPCIDataForCP(), pcieColumnNames);
            pcieSysmontable.setModel(pciemodel);

            hostCredits = new MyTableModel(di.getPCIInfo().getHostedDataForCP(), pcieColumnNames);
            hostsysmontable.setModel(hostCredits);
            //                 changing the title of the panel of host credits.
            //                System.out.println("pcie infor read");
        }
        testMode = DriverInfo.CHECKER;
        // initialize max packet size
        //ret = di.get_EngineState();
        //EngState[] engData = di.getEngState();

        if (screenMode == 6) {
            epInfo = di.getEndPointInfo();
        }
        //            System.out.println("end point infor");
    }
    //        System.out.println("moving in switch");
    //            maxSize = engData[0].MaxPktSize;
    //            sizeTextField.setText(String.valueOf(maxSize));
    switch (mode) {
    case 0://acc_perf_gen_check
           // No change in heading
           //hide all leds.
        ddricon.setVisible(false);
        DDR4label.setVisible(false);
        phy0icon.setVisible(false);
        phy0label.setVisible(false);
        phy1icon.setVisible(false);
        phty1label.setVisible(false);

        headinglable.setText("AXI-MM Dataplane : Performance Mode (GEN-CHK)");
        messageLog.append("AXI-MM Dataplane : PCIe Performance Demo\n");
        // updating block diagram
        blockdiagramlbl.setIcon(
                new ImageIcon(getClass().getResource("/com/xilinx/ultrascale/gui/BlockDiagram_pcie.jpg")));

        // resize message log.
        //                jPanel4.setPreferredSize(new Dimension(jPanel4.getWidth(), 140));
        //                jPanel4.setSize(new Dimension(jPanel4.getWidth(), 140));
        //                jPanel4.revalidate();
        //                jPanel4.repaint();
        //                DataPathPanelForOneDP.revalidate();
        break;
    case 1: {//acc_perf_gen_check_ddr
        //hide all leds.
        //                jLabel1.setVisible(false);
        //                jLabel2.setVisible(false);
        phy0icon.setVisible(false);
        phy0label.setVisible(false);
        phy1icon.setVisible(false);
        phty1label.setVisible(false);
        //                tabbedPanel.remove(statusPanel);
        headinglable.setText("AXI-MM Dataplane : Performance Mode (PCIe-DMA-DDR4)");
        blockdiagramlbl.setIcon(
                new ImageIcon(getClass().getResource("/com/xilinx/ultrascale/gui/BlockDiagram_ddr.jpg")));
        int ret = di.get_LedStats();
        LedStats lstats = di.getLedStats();
        ddrledState = lstats.ddrCalib1;
        if (lstats.ddrCalib1 == 0) {
            ddricon.setIcon(new ImageIcon(getClass().getResource("/com/xilinx/ultrascale/gui/gray.png")));
        } else {
            ddricon.setIcon(new ImageIcon(getClass().getResource("/com/xilinx/ultrascale/gui/green.png")));

        }

        // resize message log.
        //                jPanel4.setPreferredSize(new Dimension(jPanel4.getWidth(), 130));
        //                jPanel4.setSize(new Dimension(jPanel4.getWidth(), 130));
        //                jPanel4.revalidate();
        //                jPanel4.repaint();
        //                DataPathPanelForOneDP.revalidate();
        // renaming hw generator and checker
        CheckerChcekBox.setText("System to Card");
        GeneratorCheckbox.setText("Card to System");
        messageLog.append("AXI-MM Dataplane : Performance Mode (PCIe-DMA-DDR4)\n");
    }
        break;
    case 2: {//acc_application
        //hide all leds.
        sysout("will load configuration");
        phy0icon.setVisible(false);
        phy0label.setVisible(false);
        phy1icon.setVisible(false);
        phty1label.setVisible(false);
        blockdiagramlbl.setIcon(
                new ImageIcon(getClass().getResource("/com/xilinx/ultrascale/gui/BlockDiagram_video_acc.jpg")));

        int ret = di.get_LedStats();
        LedStats lstats = di.getLedStats();
        ddrledState = lstats.ddrCalib1;

        if (lstats.ddrCalib1 == 0) {
            ddricon.setIcon(new ImageIcon(getClass().getResource("/com/xilinx/ultrascale/gui/gray.png")));
        } else {
            ddricon.setIcon(new ImageIcon(getClass().getResource("/com/xilinx/ultrascale/gui/green.png")));

        }
        headinglable.setText("AXI-MM Dataplane : Video Accelerator Mode");
        messageLog2.append("AXI-MM Dataplane : Video Accelerator Mode\n");
        tabbedPanel.remove(statusPanel);
        sysout("loaded configuration");
    }
        break;
    case 3://ethernet_perf_raw
        ddricon.setVisible(false);
        DDR4label.setVisible(false);
        jCheckBox2.setEnabled(false);
        jCheckBox3.setEnabled(false);
        jCheckBox5.setEnabled(false);
        jCheckBox6.setEnabled(false);
        headinglable.setText("AXI4 Stream Dataplane : Performance mode (Raw Ethernet)");
        break;
    case 7://ethernet_perf_gen_check
        ddricon.setVisible(false);
        DDR4label.setVisible(false);
        phy0icon.setVisible(false);
        phy0label.setVisible(false);
        phy1icon.setVisible(false);
        phty1label.setVisible(false);
        headinglable.setText("AXI4 Stream Dataplane : Performance mode (GEN/CHK)");
        tabbedPanel.remove(sysmonpanel);
        tabbedPanel.setLayout(new CardLayout());
        blockdiagramlbl.setIcon(
                new ImageIcon(getClass().getResource("/com/xilinx/ultrascale/gui/BlockDiagram_Eth_GC.jpg")));
        messageLog1.append("AXI Stream Dataplane : Performance mode (GEN-CHK)\n");
        break;
    case 4://ethernet_app
        headinglable.setText("AXI4 Stream Dataplane : Application Mode");
        // disabling the controls.
        ddricon.setVisible(false);
        DDR4label.setVisible(false);
        jCheckBox1.setEnabled(false);
        jCheckBox2.setEnabled(false);
        jCheckBox3.setEnabled(false);
        jCheckBox4.setEnabled(false);
        jCheckBox5.setEnabled(false);
        jCheckBox6.setEnabled(false);
        jButton2.setEnabled(false);
        jButton3.setEnabled(false);

        break;
    case 6://control_plane
           // Set combobox values
        barComboBoxTop.removeAllItems();
        barComboBoxTop1.removeAllItems();
        barComboBoxbottom.removeAllItems();
        if (epInfo.designMode == 0) {
            barComboBoxTop.addItem("Bar2");
            barComboBoxTop1.addItem("Bar2");
            barComboBoxbottom.addItem("Bar2");
        } else if (epInfo.designMode == 1) {
            barComboBoxTop.addItem("Bar4");
            barComboBoxTop1.addItem("Bar4");
            barComboBoxbottom.addItem("Bar4");
        } else if (epInfo.designMode == 2) {
            barComboBoxTop.addItem("Bar2");
            barComboBoxTop1.addItem("Bar2");
            barComboBoxbottom.addItem("Bar2");
            barComboBoxTop.addItem("Bar4");
            barComboBoxTop1.addItem("Bar4");
            barComboBoxbottom.addItem("Bar4");
        }
        ddricon.setVisible(false);
        DDR4label.setVisible(false);
        phy0icon.setVisible(false);
        phy0label.setVisible(false);
        phy1icon.setVisible(false);
        phty1label.setVisible(false);
        tabbedPanel.remove(PerformancePlotTab);
        tabbedPanel.remove(statusPanel);
        headinglable.setText("Control Plane");
        this.setSize(this.getSize().width + 40, 610);

        jPanel1.setPreferredSize(new Dimension(279, 600));//
        jPanel1.setSize(279, 600);

        jPanel1.add(PcieEndStatuspanel);
        jPanel1.add(hostCreditsPanel);
        // pcieSysmontable.setPreferredSize(new Dimension(250, 300));
        pcieSysmontable.getColumnModel().getColumn(1).setPreferredWidth(10);
        PcieEndStatuspanel.setSize(jPanel1.getSize().width, jPanel1.getSize().height - 365);
        PcieEndStatuspanel.setLocation(new Point(0, 0));
        hostCreditsPanel.setSize(jPanel1.getSize().width, jPanel1.getSize().height - 340);
        hostCreditsPanel.setLocation(new Point(0, 250));

        ((javax.swing.border.TitledBorder) hostCreditsPanel.getBorder()).setTitle("Endpoint BAR Information");
        jPanel1.repaint();
        jPanel1.revalidate();
        //                PcieEndStatuspanel.repaint();
        //                 PcieEndStatuspanel.revalidate();
        //TabelModel.getColoum(1).setsize();
        PowerPanel.setPreferredSize(new Dimension(300, 445));
        PowerPanel.revalidate();
        PowerPanel.repaint();
        /*MyTableModel tblModel = new MyTableModel(dummydata, pcieEndptClm);
         pcieSysmontable.setModel(tblModel);
         tblModel.setData(dataForPCIEDummy, dmaColumnNames0);
         tblModel.fireTableDataChanged();*/
        MyTableModel tblModel1 = new MyTableModel(dummydata, hostPcie);
        hostsysmontable.setModel(tblModel1);
        tblModel1.setData(epInfo.getBarStats(), hostPcie);
        tblModel1.fireTableDataChanged();
        MyCellRenderer renderer = new MyCellRenderer();
        barDumpModel = new MyTableModel(bardumpDummy, bardumpNames);
        bardump.setModel(barDumpModel);
        bardump.getColumnModel().getColumn(0).setCellRenderer(renderer);
        bardump.getTableHeader().setReorderingAllowed(false);
        tabbedPanel.setLayout(new CardLayout());

        break;
    }
    alignmentsOfTables();
}

From source file:com.projity.pm.graphic.spreadsheet.SpreadSheet.java

public boolean isOnIcon(MouseEvent e) {
    Point p = e.getPoint();/*from w  ww  .j a  v  a 2 s  . com*/
    int row = rowAtPoint(p);
    int col = columnAtPoint(p);
    Rectangle bounds = getCellRect(row, col, false);
    SpreadSheetModel model = (SpreadSheetModel) getModel();
    GraphicNode node = model.getNode(row);
    return NameCellComponent.isOnIcon(
            new Point((int) (p.getX() - bounds.getX()), (int) (p.getY() - bounds.getY())), bounds.getSize(),
            model.getCache().getLevel(node));
}

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

/**
 * This tests that copying and pasting a new table into
 * the play pen works. This also confirms that the new table
 * copied is not the source of the columns.
 */// www .  j a  v  a  2  s  .  c o m
public void testPasteNewTable() throws Exception {
    SQLTable table = new SQLTable(null, "NewTable", "Remarks", "TABLE", true);
    table.addColumn(new SQLColumn(table, "NewCol1", Types.VARCHAR, 50, 0));
    table.addColumn(new SQLColumn(table, "NewCol2", Types.NUMERIC, 50, 0));

    DuplicateProperties duplicateProperties = ASUtils.createDuplicateProperties(pp.getSession(), table);
    duplicateProperties.setDefaultTransferStyle(TransferStyles.COPY);
    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);
    assertNull(copy.getColumnByName("NewCol1").getSourceColumn());
    assertNull(copy.getColumnByName("NewCol2").getSourceColumn());
}

From source file:com.diversityarrays.kdxplore.field.FieldViewDialog.java

private void handleFileDrop(Component component, List<File> files, DropLocationInfo dli) {
    Integer column = dli.column;//from  www .  ja v  a2  s  .c  o m
    Integer row = dli.rowOrIndex;

    List<Plot> plots = fieldViewPanel.getFieldLayout().getItemsAt(Arrays.asList(new Point(column, row)));

    System.out.println("Dropped on: col,row=" + column + "," + row);

    List<File> filesAdded = new ArrayList<>();
    for (Plot plot : plots) {
        System.out.println("plot: " + plot.getPlotId() + ": " + plot.getPlotColumn() + "," + plot.getPlotRow());

        List<Specimen> specimens = plot.getSpecimens();
        if (specimens == null || specimens.isEmpty()) {

            try {
                for (File file : files) {
                    File storedFile = copyToMediaStoreDir(file, plot, PlotOrSpecimen.ORGANISM_NUMBER_IS_PLOT);
                    database.addMediaFile(sampleGroupChoiceForNewMedia, trial, plot,
                            PlotOrSpecimen.ORGANISM_NUMBER_IS_PLOT, storedFile);
                    filesAdded.add(file);
                }
            } catch (IOException e) {
                e.printStackTrace();
                JOptionPane.showMessageDialog(FieldViewDialog.this, e, "Database Error",
                        JOptionPane.ERROR_MESSAGE);
                break;
            }
        } else {
            List<String> plotOrSpecimen = new ArrayList<>();
            Map<String, PlotOrSpecimen> specimenByIdent = new HashMap<>();
            String plotIdent = trial.getPlotIdentOption().createPlotIdentString(plot, ",");
            plotOrSpecimen.add(plotIdent);
            specimenByIdent.put(plotIdent, plot);
            for (Specimen s : specimens) {
                if (PlotOrSpecimen.isSpecimenNumberForSpecimen(s.getSpecimenNumber())) {
                    String ident = "Individual#" + s.getSpecimenNumber();
                    plotOrSpecimen.add(ident);
                    specimenByIdent.put(ident, s);
                }
            }
            Object[] selectionValues = plotOrSpecimen.toArray(new String[plotOrSpecimen.size()]);
            Object initialSelectionValue = null;
            Object chosen = JOptionPane.showInputDialog(FieldViewDialog.this, "Select Plot or Specimen",
                    "Add Attachment", JOptionPane.OK_CANCEL_OPTION, null, selectionValues,
                    initialSelectionValue);
            if (chosen != null) {
                PlotOrSpecimen choice = specimenByIdent.get(chosen);
                if (choice != null) {
                    try {
                        for (File file : files) {
                            File storedFile = copyToMediaStoreDir(file, plot, choice.getSpecimenNumber());
                            database.addMediaFile(sampleGroupChoiceForNewMedia, trial, plot,
                                    choice.getSpecimenNumber(), storedFile);
                            filesAdded.add(file);
                        }
                    } catch (IOException e) {
                        e.printStackTrace();
                        JOptionPane.showMessageDialog(FieldViewDialog.this, e, "Database Error",
                                JOptionPane.ERROR_MESSAGE);
                    }
                }
            }
        }
    }

    if (!filesAdded.isEmpty()) {
        String message = filesAdded.stream().map(File::getName).collect(Collectors.joining("\n"));
        JOptionPane.showMessageDialog(FieldViewDialog.this, message, "Attachments Added",
                JOptionPane.INFORMATION_MESSAGE);
    }

}

From source file:com.diversityarrays.kdxplore.curate.CurationTableModel.java

public void setTemporaryValue(CurationCellId ccid, Comparable<?> value) {

    Predicate<PlotOrSpecimen> predicate = new Predicate<PlotOrSpecimen>() {
        @Override/*w  w  w .  j a  va 2 s. co m*/
        public boolean evaluate(PlotOrSpecimen pos) {
            return ccid.specimenNumber == pos.getSpecimenNumber() && ccid.plotId == pos.getPlotId();
        }

    };

    int foundRow = -1;
    for (int row = 0; row < plotOrSpecimens.size(); ++row) {
        PlotOrSpecimen pos = plotOrSpecimens.get(row);
        if (predicate.evaluate(pos)) {
            foundRow = row;
            break;
        }
    }

    if (foundRow >= 0) {
        Integer column = getColumnIndexForTraitInstance(ccid.traitInstance);
        if (column != null) {
            Point pt = new Point(column, foundRow);
            if (value == null) {
                temporaryValues.remove(pt);
            } else {
                temporaryValues.put(pt, value);
            }

            this.fireTableCellUpdated(foundRow, column);
        }
    }
}

From source file:au.org.ala.delta.editor.ui.image.ImageOverlayEditorController.java

private void configureOverlay(ImageOverlay anOverlay) {
    Point menuPoint = _selection.getSelectedPoint();
    if (menuPoint == null) {
        menuPoint = new Point(Integer.MIN_VALUE, Integer.MIN_VALUE);
    }//from   w  ww  . ja  v  a2s .  c o  m
    OverlayLocation newLocation;
    if (anOverlay.location.size() == 0) {
        newLocation = new OverlayLocation();
        anOverlay.location.add(newLocation);
    } else {
        newLocation = anOverlay.getLocation(0);
    }

    anOverlay.setIntegralHeight(true);
    anOverlay.setHeight(-1);

    if (menuPoint.x != Integer.MIN_VALUE) {

        newLocation.setX(menuPoint.x);
        newLocation.setY(menuPoint.y);
    } else {
        newLocation.X = 350;
        newLocation.Y = 450;
    }
    if (anOverlay.isButton()) {
        int bhClient = 30;
        int bwClient = 50;
        newLocation.W = newLocation.H = Short.MIN_VALUE;
        ButtonAlignment align = _alignment;
        if (align == ButtonAlignment.NO_ALIGN)
            align = ButtonAlignment.ALIGN_VERTICALLY;
        if (menuPoint.x == Integer.MIN_VALUE) {
            newLocation.setX(align == ButtonAlignment.ALIGN_VERTICALLY ? 800 : 500);
            newLocation.setY(align == ButtonAlignment.ALIGN_VERTICALLY ? 500 : 800);
        }
        newLocation.setX(Math.max(0, Math.min(1000 - bwClient, (int) newLocation.X)));
        newLocation.setY(Math.max(0, Math.min(1000 - bhClient, (int) newLocation.Y)));
        int okWhere = Integer.MIN_VALUE, cancelWhere = Integer.MIN_VALUE, notesWhere = Integer.MIN_VALUE;
        ImageOverlay okOverlay = _selection.getSelectedImage().getOverlay(OverlayType.OLOK);
        if (okOverlay != null) {
            if (align == ButtonAlignment.ALIGN_VERTICALLY) {
                newLocation.setX(okOverlay.getX());
                okWhere = okOverlay.getY();
            } else if (align == ButtonAlignment.ALIGN_HORIZONTALLY) {
                newLocation.setY(okOverlay.getY());
                okWhere = okOverlay.getX();
            }
        }
        ImageOverlay cancelOverlay = _selection.getSelectedImage().getOverlay(OverlayType.OLCANCEL);
        if (cancelOverlay != null) {
            if (align == ButtonAlignment.ALIGN_VERTICALLY) {
                newLocation.setX(cancelOverlay.getX());
                cancelWhere = cancelOverlay.getY();
            } else if (align == ButtonAlignment.ALIGN_HORIZONTALLY) {
                newLocation.setY(cancelOverlay.getY());
                cancelWhere = cancelOverlay.getX();
            }
        }
        ImageOverlay notesOverlay;
        if (isCharacterIllustrated())
            notesOverlay = _selection.getSelectedImage().getOverlay(OverlayType.OLNOTES);
        else
            notesOverlay = _selection.getSelectedImage().getOverlay(OverlayType.OLIMAGENOTES);
        if (notesOverlay != null) {
            if (align == ButtonAlignment.ALIGN_VERTICALLY) {
                newLocation.setX(notesOverlay.getX());
                notesWhere = notesOverlay.getY();
            } else if (align == ButtonAlignment.ALIGN_HORIZONTALLY) {
                newLocation.setY(notesOverlay.getY());
                notesWhere = notesOverlay.getX();
            }
        }
        int newWhere = Integer.MIN_VALUE;
        int size = 0;
        if (align == ButtonAlignment.ALIGN_VERTICALLY)
            size = bhClient;
        else if (align == ButtonAlignment.ALIGN_HORIZONTALLY)
            size = bwClient;
        int space = size + (size + 1) / 2;
        if (anOverlay.type == OverlayType.OLOK) {
            if (cancelWhere != Integer.MIN_VALUE && notesWhere != Integer.MIN_VALUE)
                newWhere = cancelWhere - Math.abs(notesWhere - cancelWhere);
            else if (cancelWhere != Integer.MIN_VALUE || notesWhere != Integer.MIN_VALUE)
                newWhere = Math.max(cancelWhere, notesWhere) - space;
        } else if (anOverlay.type == OverlayType.OLCANCEL) {
            if (okWhere != Integer.MIN_VALUE && notesWhere != Integer.MIN_VALUE)
                newWhere = (okWhere + notesWhere) / 2;
            else if (okWhere != Integer.MIN_VALUE)
                newWhere = okWhere + space;
            else if (notesWhere != Integer.MIN_VALUE)
                newWhere = notesWhere - space;
        }
        if (anOverlay.type == OverlayType.OLNOTES || anOverlay.type == OverlayType.OLIMAGENOTES) {
            if (okWhere != Integer.MIN_VALUE && cancelWhere != Integer.MIN_VALUE)
                newWhere = cancelWhere + Math.abs(cancelWhere - okWhere);
            else if (okWhere != Integer.MIN_VALUE || cancelWhere != Integer.MIN_VALUE)
                newWhere = Math.max(okWhere, cancelWhere) + space;
        }
        if (newWhere + size > 1000)
            newWhere = 1000 - size;
        if (newWhere != Integer.MIN_VALUE) {
            if (newWhere < 0)
                newWhere = 0;
            if (align == ButtonAlignment.ALIGN_VERTICALLY)
                newLocation.setY(newWhere);
            else if (align == ButtonAlignment.ALIGN_HORIZONTALLY)
                newLocation.setX(newWhere);
        }
    } else if (anOverlay.type == OverlayType.OLHOTSPOT)
        newLocation.setW(Math.min(200, 1000 - newLocation.X));
    else
        newLocation.setW(Math.min(300, 1000 - newLocation.X));

}

From source file:com.projity.pm.graphic.spreadsheet.SpreadSheet.java

public boolean isOnText(MouseEvent e) {
    Point p = e.getPoint();//from   ww w .  j  a  v  a 2 s  .  c om
    int row = rowAtPoint(p);
    int col = columnAtPoint(p);
    Rectangle bounds = getCellRect(row, col, false);
    SpreadSheetModel model = (SpreadSheetModel) getModel();
    GraphicNode node = model.getNode(row);
    return NameCellComponent.isOnText(
            new Point((int) (p.getX() - bounds.getX()), (int) (p.getY() - bounds.getY())), bounds.getSize(),
            model.getCache().getLevel(node));
}

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

/**
 * Sets up everything in common between all types of playpens.
 * //from  ww w .java 2s  . c  o m
 * @param pp
 *            the play pen to set up
 * @param attributes
 *            The attributes from the start tag
 */
private void setupGenericPlayPen(PlayPen pp, Attributes attributes) {
    String zoomLevel = attributes.getValue("zoom"); //$NON-NLS-1$
    if (zoomLevel != null) {
        pp.setZoom(Double.parseDouble(zoomLevel));
    }

    String viewportX = attributes.getValue("viewportX"); //$NON-NLS-1$
    String viewportY = attributes.getValue("viewportY"); //$NON-NLS-1$

    if (viewportX != null && viewportY != null) {
        Point viewPoint = new Point(Integer.parseInt(viewportX), Integer.parseInt(viewportY));
        pp.setViewPosition(viewPoint);
    }
    logger.debug("Viewport position is " + pp.getViewPosition()); //$NON-NLS-1$
}