List of usage examples for java.awt Point Point
public Point(int x, int y)
From source file:fr.landel.utils.commons.CollectionUtils2Test.java
/** * Test method for {@link CollectionUtils2#transformIntoArray(I[])}. *//*www . ja v a2 s. co m*/ @Test public void testTransformIntoArrayIArray() { try { Point[] points = new Point[3]; points[0] = new Point(1, 2); points[1] = new Point(2, 0); String[] pointsArray = CollectionUtils2.transformIntoArray(points); assertNotNull(pointsArray); assertTrue(pointsArray.length > 0); assertThat(pointsArray, Matchers.arrayContaining("java.awt.Point[x=1,y=2]", "java.awt.Point[x=2,y=0]", null)); } catch (IllegalArgumentException e) { fail("The test isn't correct"); } }
From source file:net.pandoragames.far.ui.swing.component.FileListPopupMenu.java
/** * Overwrites the method of the superclass to fetch mouse coordinates * and to deduce the selected row of the file list table. *//*w ww . j a v a 2 s.co m*/ public void show(Component jTable, int mouseX, int mouseY) { Point mousePointer = new Point(mouseX, mouseY); selectedRow = fileTable.rowAtPoint(mousePointer); if (fileTable.getSelectedRowCount() == 1) { viewAction.setSelectedFile(tableModel.getRow(selectedRow)); previewAction.setSelectedFile(tableModel.getRow(selectedRow)); } else { viewAction.setSelectedFile(null); previewAction.setSelectedFile(null); } enableItems(fileTable.getSelectedRowCount() < 2, tableModel.getRow(selectedRow).getFile().exists()); super.show(jTable, mouseX, mouseY); }
From source file:org.martus.client.swingui.PureFxMainWindow.java
public Point getMainWindowLocation() { int x = (int) realStage.getX(); int y = (int) realStage.getY(); return new Point(x, y); }
From source file:org.broad.igv.util.stats.KMPlotFrame.java
private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents // Generated using JFormDesigner non-commercial license dialogPane = new JPanel(); contentPanel = new JPanel(); panel1 = new JPanel(); panel2 = new JPanel(); label2 = new JLabel(); survivalColumnControl = new JComboBox(); panel3 = new JPanel(); label3 = new JLabel(); censurColumnControl = new JComboBox(); panel4 = new JPanel(); label4 = new JLabel(); groupByControl = new JComboBox(); //======== this ======== setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); setTitle("Kaplan-Meier Plot"); Container contentPane = getContentPane(); contentPane.setLayout(new BorderLayout()); //======== dialogPane ======== {/* w w w .ja v a2 s. c om*/ dialogPane.setBorder(new EmptyBorder(12, 12, 12, 12)); dialogPane.setLayout(new BorderLayout()); //======== contentPanel ======== { contentPanel.setLayout(new BorderLayout()); //======== panel1 ======== { panel1.setAlignmentX(0.0F); panel1.setLayout(new BoxLayout(panel1, BoxLayout.Y_AXIS)); //======== panel2 ======== { panel2.setAlignmentX(1.0F); panel2.setLayout(null); //---- label2 ---- label2.setText("Survival column"); panel2.add(label2); label2.setBounds(new Rectangle(new Point(5, 10), label2.getPreferredSize())); //---- survivalColumnControl ---- survivalColumnControl.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { survivalColumnControlActionPerformed(e); } }); panel2.add(survivalColumnControl); survivalColumnControl.setBounds(120, 5, 235, survivalColumnControl.getPreferredSize().height); { // compute preferred size Dimension preferredSize = new Dimension(); for (int i = 0; i < panel2.getComponentCount(); i++) { Rectangle bounds = panel2.getComponent(i).getBounds(); preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width); preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height); } Insets insets = panel2.getInsets(); preferredSize.width += insets.right; preferredSize.height += insets.bottom; panel2.setMinimumSize(preferredSize); panel2.setPreferredSize(preferredSize); } } panel1.add(panel2); //======== panel3 ======== { panel3.setAlignmentX(1.0F); panel3.setLayout(null); //---- label3 ---- label3.setText("Censure column"); panel3.add(label3); label3.setBounds(new Rectangle(new Point(5, 10), label3.getPreferredSize())); //---- censurColumnControl ---- censurColumnControl.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { survivalColumnControlActionPerformed(e); } }); panel3.add(censurColumnControl); censurColumnControl.setBounds(120, 5, 235, censurColumnControl.getPreferredSize().height); { // compute preferred size Dimension preferredSize = new Dimension(); for (int i = 0; i < panel3.getComponentCount(); i++) { Rectangle bounds = panel3.getComponent(i).getBounds(); preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width); preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height); } Insets insets = panel3.getInsets(); preferredSize.width += insets.right; preferredSize.height += insets.bottom; panel3.setMinimumSize(preferredSize); panel3.setPreferredSize(preferredSize); } } panel1.add(panel3); //======== panel4 ======== { panel4.setAlignmentX(1.0F); panel4.setLayout(null); //---- label4 ---- label4.setText("Group by"); panel4.add(label4); label4.setBounds(new Rectangle(new Point(5, 10), label4.getPreferredSize())); //---- groupByControl ---- groupByControl.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { survivalColumnControlActionPerformed(e); } }); panel4.add(groupByControl); groupByControl.setBounds(120, 5, 235, groupByControl.getPreferredSize().height); { // compute preferred size Dimension preferredSize = new Dimension(); for (int i = 0; i < panel4.getComponentCount(); i++) { Rectangle bounds = panel4.getComponent(i).getBounds(); preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width); preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height); } Insets insets = panel4.getInsets(); preferredSize.width += insets.right; preferredSize.height += insets.bottom; panel4.setMinimumSize(preferredSize); panel4.setPreferredSize(preferredSize); } } panel1.add(panel4); } contentPanel.add(panel1, BorderLayout.NORTH); } dialogPane.add(contentPanel, BorderLayout.CENTER); } contentPane.add(dialogPane, BorderLayout.CENTER); setSize(565, 510); setLocationRelativeTo(getOwner()); // JFormDesigner - End of component initialization //GEN-END:initComponents }
From source file:it.unibas.spicygui.controllo.provider.intermediatezone.WidgetCreator.java
public Widget createFunctionWidget(Scene scene, LayerWidget mainLayer, LayerWidget connectionLayer, JPanel pannelloPrincipale, Point point, GraphSceneGlassPane glassPane) { FunctionWidget rootWidget = new FunctionWidget(scene, point); CaratteristicheWidgetInterFunction caratteristicheWidget = new CaratteristicheWidgetInterFunction(); //giannisk// w ww.j av a 2s .c om caratteristicheWidget.setTgdView(false); caratteristicheWidget.setTreeType(Costanti.INTERMEDIE); rootWidget.getActions() .addAction(ActionFactory.createEditAction(new MyEditProviderFunction(caratteristicheWidget))); rootWidget.getActions().addAction(ActionFactory.createConnectAction(connectionLayer, new ActionFunctionConnection(connectionLayer, mainLayer, caratteristicheWidget))); rootWidget.getActions() .addAction(ActionFactory.createPopupMenuAction(new MyPopupProviderDeleteFunc(glassPane))); 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); IntermediateMoveProvider moveProvider = new IntermediateMoveProvider(pannelloPrincipale); barra.getActions().addAction(ActionFactory.createMoveAction(moveProvider, moveProvider)); caratteristicheWidget.setWidgetBarra(barra); mainLayer.addChild(rootWidget, caratteristicheWidget); mainLayer.addChild(barra, caratteristicheBarra); glassPane.addFunction(rootWidget); glassPane.addFunction(barra); return rootWidget; }
From source file:cz.muni.fi.javaseminar.kafa.bookregister.gui.MainWindow.java
private void initAuthorsTable() { authorsTable.getColumnModel().getColumn(2) .setCellEditor(new DatePickerCellEditor(new SimpleDateFormat("dd. MM. yyyy"))); authorsTable.getColumnModel().getColumn(2).setCellRenderer(new DefaultTableCellRenderer() { @Override// ww w . j a va 2 s . c o m public Component getTableCellRendererComponent(JTable jtable, Object value, boolean selected, boolean hasFocus, int row, int column) { if (value instanceof Date) { // You could use SimpleDateFormatter instead value = new SimpleDateFormat("dd. MM. yyyy").format(value); } return super.getTableCellRendererComponent(jtable, value, selected, hasFocus, row, column); } }); authorsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); ListSelectionModel selectionModel = authorsTable.getSelectionModel(); selectionModel.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { DefaultListSelectionModel source = (DefaultListSelectionModel) e.getSource(); if (source.getMinSelectionIndex() >= 0) { authorsTableModel.setCurrentSlectedIndex(source.getMinSelectionIndex()); } if (!e.getValueIsAdjusting()) { booksTableModel.setAuthorIndex(source.getMinSelectionIndex()); } } }); authorsTable.getColumnModel().getColumn(2) .setCellEditor(new DatePickerCellEditor(new SimpleDateFormat("dd. MM. yyyy"))); authorsTable.getColumnModel().getColumn(2).setCellRenderer(new DefaultTableCellRenderer() { @Override public Component getTableCellRendererComponent(JTable jtable, Object value, boolean selected, boolean hasFocus, int row, int column) { if (value instanceof Date) { // You could use SimpleDateFormatter instead value = new SimpleDateFormat("dd. MM. yyyy").format(value); } return super.getTableCellRendererComponent(jtable, value, selected, hasFocus, row, column); } }); JPopupMenu authorsPopupMenu = new JPopupMenu(); JMenuItem deleteItem = new JMenuItem("Delete"); authorsPopupMenu.addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { int rowAtPoint = authorsTable.rowAtPoint( SwingUtilities.convertPoint(authorsPopupMenu, new Point(0, 0), authorsTable)); if (rowAtPoint > -1) { authorsTable.setRowSelectionInterval(rowAtPoint, rowAtPoint); authorsTableModel.setCurrentSlectedIndex(rowAtPoint); } } }); } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { // TODO Auto-generated method stub } @Override public void popupMenuCanceled(PopupMenuEvent e) { // TODO Auto-generated method stub } }); deleteItem.addActionListener(new ActionListener() { private Author author; @Override public void actionPerformed(ActionEvent e) { new SwingWorker<Void, Void>() { @Override protected Void doInBackground() throws Exception { author = authorsTableModel.getAuthors().get(authorsTable.getSelectedRow()); log.debug("Deleting author: " + author.getFirstname() + " " + author.getSurname() + " from database."); authorManager.deleteAuthor(author); return null; } @Override protected void done() { try { get(); } catch (InterruptedException | ExecutionException e) { if (e.getCause() instanceof DataIntegrityViolationException) { JOptionPane.showMessageDialog(MainWindow.this, "Couldn't delete author; there are still some books assigned to him.", "Error", JOptionPane.ERROR_MESSAGE); } log.error("There was an exception thrown during deletion author: " + author.getFirstname() + " " + author.getSurname(), e); return; } updateModel(); } }.execute(); } }); authorsPopupMenu.add(deleteItem); authorsTable.setComponentPopupMenu(authorsPopupMenu); }
From source file:fr.landel.utils.commons.CollectionUtils2Test.java
/** * Test method for {@link CollectionUtils2#transformIntoArray(I[], boolean)} * .//from www. j a v a2 s . co m */ @Test public void testTransformIntoArrayIArrayB() { try { Point[] points = new Point[3]; points[0] = new Point(1, 2); points[1] = new Point(2, 0); String[] pointsArray = CollectionUtils2.transformIntoArray(points, true); assertNotNull(pointsArray); assertTrue(pointsArray.length > 0); assertThat(pointsArray, Matchers.arrayContaining("java.awt.Point[x=1,y=2]", "java.awt.Point[x=2,y=0]", "null")); points = new Point[0]; pointsArray = CollectionUtils2.transformIntoArray(points, true); assertNull(pointsArray); } catch (IllegalArgumentException e) { fail("The test isn't correct"); } }
From source file:com.igormaznitsa.sciareto.ui.editors.MMDEditor.java
public void topicToCentre(@Nullable final Topic topic) { if (topic != null) { SwingUtilities.invokeLater(new Runnable() { @Override/*from ww w .j a va2 s . co m*/ public void run() { final AbstractElement element = (AbstractElement) Assertions.assertNotNull(topic).getPayload(); if (element != null) { final Rectangle2D bounds = element.getBounds(); final Dimension viewPortSize = getViewport().getExtentSize(); final int x = Math.max(0, (int) Math .round(bounds.getX() - (viewPortSize.getWidth() - bounds.getWidth()) / 2)); final int y = Math.max(0, (int) Math .round(bounds.getY() - (viewPortSize.getHeight() - bounds.getHeight()) / 2)); getViewport().setViewPosition(new Point(x, y)); } } }); } }
From source file:it.unibas.spicygui.controllo.datasource.operators.CreaWidgetAlberiLogic.java
public INode createSingleJoin(PathExpression fromPath, IDataSourceProxy dataSource, PathExpression toPath, boolean source, JoinConstraint joinConstraint) { createCollections();/* w w w . j ava 2 s . c o m*/ INode iNodeFromPath = finder.findNodeInSchema(fromPath, dataSource); INode iNodeToPath = finder.findNodeInSchema(toPath, dataSource); Widget widgetFromPathOriginale = (Widget) iNodeFromPath.getAnnotation(pinWidgetTreeConstant); Widget widgetToPathOriginale = (Widget) iNodeToPath.getAnnotation(pinWidgetTreeConstant); //TODO migliorare questo controllo, per non ripetere molte volte questo if if (constraintsLayer == null || scene == null) { scene = widgetFromPathOriginale.getScene(); constraintsLayer = (LayerWidget) scene.getChildren().get(Costanti.INDEX_CONSTRAINTS_LAYER); } VMDPinWidgetKey widgetFromPath = new VMDPinWidgetKey(scene); VMDPinWidgetKey widgetToPath = new VMDPinWidgetKey(scene); settaWidgetKey(widgetFromPath); settaWidgetKey(widgetToPath); int ascissa = getAscissaMaggiore(widgetFromPathOriginale, widgetToPathOriginale); Point pointFromPath = null; Point pointToPath = null; if (source) { pointFromPath = new Point(ascissa + OFFSET_ASCISSA_SOURCE, widgetFromPathOriginale.getPreferredLocation().y + OFFSET_ORDINATA_SOURCE); pointToPath = new Point(ascissa + OFFSET_ASCISSA_SOURCE, widgetToPathOriginale.getPreferredLocation().y + OFFSET_ORDINATA_SOURCE); } else { pointFromPath = new Point(ascissa + OFFSET_ASCISSA_TARGET, widgetFromPathOriginale.getPreferredLocation().y + OFFSET_ORDINATA_TARGET); pointToPath = new Point(ascissa + OFFSET_ASCISSA_TARGET, widgetToPathOriginale.getPreferredLocation().y); } LineCoordinates lineCoordinates = new LineCoordinates(pointFromPath, pointToPath); lineCoordinatesCollections.calculateFreeCoordinate(lineCoordinates); lineCoordinatesCollections.addLineCoordinates(lineCoordinates); widgetFromPath.setPreferredLocation(pointFromPath); widgetToPath.setPreferredLocation(pointToPath); ConnectionConstraint connectionConstraint = createConnectionConstraint(source, widgetToPathOriginale, widgetFromPathOriginale, widgetFromPath, ascissa, widgetToPath, Costanti.DASHED_STROKE, joinConstraint); joinConstraint.addConnection(connectionConstraint); // connection.getActions().addAction(ActionFactory.createPopupMenuAction(new MyPopupProviderJoinCondition(scene, constraintsLayer))); return iNodeFromPath; }
From source file:net.sf.webphotos.tools.Thumbnail.java
private static Point calculaPosicao(Dimension dimensaoExt, Dimension dimensaoInt, int margem, int posicao) { int x = 0, y = 0; // Posio da marca d'agua // 1---2---3 y1 // 4---5---6 y2 // 7---8---9 y3 // x1 x2 x3 int x1 = margem; int x2 = (int) ((float) (dimensaoExt.width - dimensaoInt.width) / 2); int x3 = dimensaoExt.width - dimensaoInt.width - margem; int y1 = margem; int y2 = (int) ((float) (dimensaoExt.height - dimensaoInt.height) / 2); int y3 = dimensaoExt.height - dimensaoInt.height - margem; if (posicao == 1) { x = x1;/* www . jav a 2 s .c o m*/ y = y1; } else if (posicao == 2) { x = x2; y = y1; } else if (posicao == 3) { x = x3; y = y1; } else if (posicao == 4) { x = x1; y = y2; } else if (posicao == 5) { x = x2; y = y2; } else if (posicao == 6) { x = x3; y = y2; } else if (posicao == 7) { x = x1; y = y3; } else if (posicao == 8) { x = x2; y = y3; } else if (posicao == 9) { x = x3; y = y3; } return new Point(x, y); }