List of usage examples for java.awt Point Point
public Point(int x, int y)
From source file:business.ImageManager.java
public void doDrawPathNpc(Graphics2D big, Point ori, Point dest) { final int x = 04 + 7 / 2 + 8; final int y = 22 + 13 / 2 - 2; doDrawPath(big, new Point((int) ori.getX() + x, (int) ori.getY() + y), new Point((int) dest.getX() + x, (int) dest.getY() + y), colorNpc); }
From source file:it.geosolutions.imageio.plugins.nitronitf.ImageIOUtils.java
/** * Returns a generic pixel interleaved WritableRaster * // w w w . ja va 2s . c o m * @param numElems * @param numLines * @param bandOffsets * @param dataType * @return */ public static WritableRaster makeGenericPixelInterleavedWritableRaster(int numElems, int numLines, int numBands, int dataType) { int[] bandOffsets = new int[numBands]; for (int i = 0; i < numBands; ++i) bandOffsets[i] = i; DataBuffer d = null; if (dataType == DataBuffer.TYPE_BYTE) d = new DataBufferByte(numElems * numLines * numBands); else if (dataType == DataBuffer.TYPE_SHORT) d = new DataBufferShort(numElems * numLines * numBands); else if (dataType == DataBuffer.TYPE_USHORT) d = new DataBufferUShort(numElems * numLines * numBands); else if (dataType == DataBuffer.TYPE_FLOAT) d = new DataBufferFloat(numElems * numLines * numBands); else if (dataType == DataBuffer.TYPE_DOUBLE) d = new DataBufferDouble(numElems * numLines * numBands); else throw new IllegalArgumentException("Invalid datatype: " + dataType); PixelInterleavedSampleModel pism = new PixelInterleavedSampleModel(dataType, numElems, numLines, bandOffsets.length, numElems * bandOffsets.length, bandOffsets); SunWritableRaster ras = new SunWritableRaster(pism, d, new Point(0, 0)); return ras; }
From source file:Animator.java
/** * Parse a String of form xxx@yyy and return a Point. *//*w w w . j av a 2 s.c o m*/ Point parsePoint(String s) throws ParseException { int atPos = s.indexOf('@'); if (atPos == -1) throw new ParseException("Illegal position: " + s); return new Point(Integer.parseInt(s.substring(0, atPos)), Integer.parseInt(s.substring(atPos + 1))); }
From source file:simMPLS.scenario.TReceiverNode.java
/** * Este mtodo deserializa un nodo serializado pasado por parmetro, * reconstruyendolo en memoria en la instancia actual. * @param elemento Nodo receptor serializado. * @return TRUE, si se ha podido deserializar correctamente. FALSE en caso contrario. * @since 1.0/*from www . j a v a 2 s. c o m*/ */ @Override public boolean unMarshall(String elemento) { String valores[] = elemento.split("#"); if (valores.length != 9) { return false; } this.setID(Integer.parseInt(valores[2])); this.setName(valores[3]); this.setIPAddress(valores[4]); this.setStatus(0); this.setShowName(Boolean.parseBoolean(valores[5])); this.setGenerateStats(Boolean.parseBoolean(valores[6])); int posX = Integer.parseInt(valores[7]); int posY = Integer.parseInt(valores[8]); this.setPosition(new Point(posX + 24, posY + 24)); return true; }
From source file:dk.dma.epd.common.prototype.gui.notification.MsiNmNotificationPanel.java
/** * {@inheritDoc}//from ww w . j a v a 2 s.c o m */ @Override public void setNotification(MsiNmNotification notification) { this.notification = notification; // Special case if (notification == null) { contentPane.setText(""); scrollPane.getViewport().setViewPosition(new Point(0, 0)); return; } MCMessage message = notification.get(); MCMessageDesc desc = message.getDescs().size() > 0 ? message.getDescs().get(0) : null; StringBuilder html = new StringBuilder("<html>"); html.append("<table>"); // Title line html.append("<tr><td colspan='2'>"); if (message.getOriginalInformation() != null && message.getOriginalInformation()) { html.append("<strong>✭</strong><br/>"); } html.append("<b>").append(notification.getSeriesId()).append(". ") .append(notification.getAreaLineage(0, 100)); if (desc != null && StringUtils.isNotBlank(desc.getTitle())) { html.append(" - ").append(desc.getTitle()); } html.append("</b></td></tr>"); // References for (MCReference ref : message.getReferences()) { String id = notification.formatSeriesId(ref.getSeriesIdentifier()); append(html, "Reference", String.format("<a href='http://msinm/%s'>%s</a> (%s)", id, id, ref.getType().name().toLowerCase())); } // Time if (desc != null && StringUtils.isNotBlank(desc.getTime())) { append(html, "Time", desc.getTime().trim().replace("\n", "<br/>")); } else { String time = Formatter.formatShortDateTime(new Date(message.getValidFrom().getTime())); if (message.getValidTo() != null) { time += " - " + Formatter.formatShortDateTime(new Date(message.getValidTo().getTime())); } append(html, "Time", time); } // Locations if (message.getLocations().size() > 0) { StringBuilder location = new StringBuilder(); for (MCLocation loc : message.getLocations()) { location.append("<p>"); formatLoc(location, loc); location.append("</p>"); } append(html, "Location", location.toString()); } if (desc != null) { append(html, "Details", desc.getDescription()); append(html, "Note", desc.getNote()); append(html, "Publication", desc.getPublication()); append(html, "Source", desc.getSource()); } // Charts if (message.getCharts().size() > 0) { StringBuilder charts = new StringBuilder(); for (MCChart chart : message.getCharts()) { charts.append(chart.getChartNumber()); if (chart.getInternationalNumber() != null) { charts.append(String.format(" (INT %d)", chart.getInternationalNumber())); } charts.append("<br/>"); } append(html, "Charts", charts.toString()); } if (message.getAttachments().size() > 0) { StringBuilder attachments = new StringBuilder(); for (MCAttachment att : message.getAttachments()) { attachments.append("<div style='text-align: center; margin-bottom: 10px;'>"); attachments.append(String.format( "<div style='display: inline-block; vertical-align: middle;'><a href='%s'><img src='%s?size=32' border='0'></a></div>", att.getPath(), att.getThumbnail())); attachments.append(String.format("<div><a href='%s'>%s</a></div>", att.getPath(), att.getName())); attachments.append("</div>"); } append(html, "Attachments", attachments.toString()); } html.append("</table>"); html.append("</html>"); contentPane.setText(html.toString()); scrollPane.getViewport().setViewPosition(new Point(0, 0)); }
From source file:io.gameover.utilities.pixeleditor.Pixelizer.java
private void clearSelection() { this.frameCopied = null; for (int i = 0; i < selectionMask.length; i++) { for (int j = 0; j < selectionMask[0].length; j++) { selectionMask[i][j] = false; }//from ww w. j a v a 2s . co m } selectionPoint = new Point(0, 0); repaint(); }
From source file:business.ImageManager.java
public void doDrawPathPcEnemy(Graphics2D big, Point ori, Point dest) { final int x = 04 + 7 / 2 + 6; final int y = 22 + 13 / 2 - 3 + 4; doDrawPath(big, new Point((int) ori.getX() + x, (int) ori.getY() + y), new Point((int) dest.getX() + x, (int) dest.getY() + y), colorEnemy); }
From source file:fr.landel.utils.commons.CollectionUtils2Test.java
/** * Test method for// w ww.j ava 2 s .c o m * {@link CollectionUtils2#transformIntoArray(java.lang.Iterable)}. */ @Test public void testTransformIntoArrayIterableOfI() { try { List<Point> points = new ArrayList<>(); points.add(new Point(1, 2)); points.add(new Point(2, 0)); points.add(null); 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:it.unibas.spicygui.controllo.datasource.operators.CreaWidgetAlberiLogic.java
private ConnectionConstraint createConnectionConstraint(boolean source, Widget widgetKeyOriginale, Widget widgetForeignKeyOriginale, VMDPinWidgetKey widgetForeignKey, int ascissa, VMDPinWidgetKey widgetKey, Stroke stroke, JoinConstraint joinConstraint) { Point originalPointForeignKey = widgetForeignKeyOriginale.getPreferredLocation(); Point originalPointKey = widgetKeyOriginale.getPreferredLocation(); Point newPointForeignKey = new Point(originalPointForeignKey.x, originalPointForeignKey.y); Point newPointKey = new Point(originalPointKey.x, originalPointKey.y); LayerWidget mainLayer = (LayerWidget) widgetKeyOriginale.getParentWidget(); mainLayer.addChild(widgetForeignKey, new CaratteristicheWidgetConstraint(Costanti.FOREIGN_KEY, widgetForeignKeyOriginale, newPointForeignKey)); mainLayer.addChild(widgetKey,/*from w ww. ja v a 2 s . c om*/ new CaratteristicheWidgetConstraint(Costanti.KEY, widgetKeyOriginale, newPointKey)); ConnectionConstraint connectionConstraint = new ConnectionConstraint(); VMDPinWidgetKey widgetIntermediateForeignKey = new VMDPinWidgetKey(scene); VMDPinWidgetKey widgetIntermediateKey = new VMDPinWidgetKey(scene); settaWidgetKey(widgetIntermediateForeignKey); settaWidgetKey(widgetIntermediateKey); Point keyPoint = null; if (source) { widgetIntermediateForeignKey.setPreferredLocation(new Point( widgetForeignKeyOriginale.getPreferredLocation().x + OFFSET_ASCISSA_SOURCE_SECONDO_WIDGET, widgetForeignKeyOriginale.getPreferredLocation().y + OFFSET_ORDINATA_TARGET)); keyPoint = new Point(widgetKeyOriginale.getPreferredLocation().x + OFFSET_ASCISSA_SOURCE_SECONDO_WIDGET, widgetKeyOriginale.getPreferredLocation().y); } else { widgetIntermediateForeignKey.setPreferredLocation(new Point( widgetForeignKeyOriginale.getPreferredLocation().x + OFFSET_ASCISSA_TARGET_SECONDO_WIDGET, widgetForeignKeyOriginale.getPreferredLocation().y + OFFSET_ORDINATA_TARGET)); keyPoint = new Point(widgetKeyOriginale.getPreferredLocation().x + OFFSET_ASCISSA_TARGET_SECONDO_WIDGET, widgetKeyOriginale.getPreferredLocation().y); } repositionatingWidgetConstraints(keyPoint, widgetKey, widgetIntermediateKey); mainLayer.addChild(widgetIntermediateForeignKey, new CaratteristicheWidgetConstraint(Costanti.FOREIGN_KEY, widgetForeignKeyOriginale, newPointForeignKey)); mainLayer.addChild(widgetIntermediateKey, new CaratteristicheWidgetConstraint(Costanti.KEY, widgetKeyOriginale, newPointKey)); MyConnectionWidget mcw1 = creaConnection(widgetKey, widgetIntermediateKey, true, stroke, joinConstraint); MyConnectionWidget mcw2 = creaConnection(widgetKey, widgetForeignKey, false, stroke, joinConstraint); MyConnectionWidget mcw3 = creaConnection(widgetIntermediateForeignKey, widgetForeignKey, false, stroke, joinConstraint); createPopupJoinCondition(joinConstraint, Arrays.asList(mcw1, mcw2, mcw3)); connectionConstraint.addConnection(mcw1); connectionConstraint.addConnection(mcw2); connectionConstraint.addConnection(mcw3); scene.validate(); scene.paint(); scene.repaint(); scene.revalidate(); return connectionConstraint; }
From source file:com.mirth.connect.client.ui.dependencies.ChannelDependenciesPanel.java
private void initComponents() { setBackground(UIConstants.BACKGROUND_COLOR); dependencyLabel = new JLabel("This channel depends upon:"); dependencyTreeTable = new MirthTreeTable(); DefaultTreeTableModel dependencyModel = new SortableTreeTableModel(); DefaultMutableTreeTableNode dependencyRootNode = new DefaultMutableTreeTableNode(); dependencyModel.setRoot(dependencyRootNode); dependencyTreeTable.setTreeTableModel(dependencyModel); dependencyTreeTable.setRootVisible(false); dependencyTreeTable.setDoubleBuffered(true); dependencyTreeTable.setDragEnabled(false); dependencyTreeTable.setRowSelectionAllowed(true); dependencyTreeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); dependencyTreeTable.setRowHeight(UIConstants.ROW_HEIGHT); dependencyTreeTable.setFocusable(true); dependencyTreeTable.setOpaque(true); dependencyTreeTable.setEditable(false); dependencyTreeTable.setSortable(true); dependencyTreeTable.putClientProperty("JTree.lineStyle", "Horizontal"); dependencyTreeTable.setAutoCreateColumnsFromModel(false); dependencyTreeTable.setShowGrid(true, true); dependencyTreeTable.setTableHeader(null); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { dependencyTreeTable.setHighlighters(HighlighterFactory .createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR)); }// w ww . j a va 2 s . c o m dependencyTreeTable.setTreeCellRenderer(new DependencyTreeCellRenderer(dependencyTreeTable)); dependencyTreeTable.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent evt) { checkSelection(evt); } @Override public void mouseReleased(MouseEvent evt) { checkSelection(evt); } private void checkSelection(MouseEvent evt) { if (dependencyTreeTable.rowAtPoint(new Point(evt.getX(), evt.getY())) < 0) { dependencyTreeTable.clearSelection(); } } }); dependencyTreeTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent evt) { if (!evt.getValueIsAdjusting()) { boolean removeEnabled = false; int[] rows = dependencyTreeTable.getSelectedModelRows(); if (rows.length == 1) { TreePath selectedPath = dependencyTreeTable.getPathForRow(rows[0]); if (selectedPath != null) { if (selectedPath.getPathCount() == 2) { removeEnabled = true; } } } dependencyRemoveButton.setEnabled(removeEnabled); } } }); dependencyScrollPane = new JScrollPane(dependencyTreeTable); dependencyExpandAllLabel = new JLabel("<html><u>Expand All</u></html>"); dependencyExpandAllLabel.setForeground(Color.BLUE); dependencyExpandAllLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); dependencyExpandAllLabel.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent evt) { dependencyTreeTable.expandAll(); } }); dependencyCollapseAllLabel = new JLabel("<html><u>Collapse All</u></html>"); dependencyCollapseAllLabel.setForeground(Color.BLUE); dependencyCollapseAllLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); dependencyCollapseAllLabel.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent evt) { dependencyTreeTable.collapseAll(); } }); dependencyAddButton = new JButton("Add"); dependencyAddButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { Map<String, String> allowedChannelsMap = getAllowedChannels(true); if (MapUtils.isNotEmpty(allowedChannelsMap)) { AddDialog dialog = new AddDialog(allowedChannelsMap, true); if (dialog.wasSaved()) { for (String dependencyId : dialog.getSelectedChannelIds()) { dependencies.add(new ChannelDependency(channel.getId(), dependencyId)); } updateTreeTable(true, dependencies); updateAddButton(); } } } }); dependencyRemoveButton = new JButton("Remove"); dependencyRemoveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { int[] rows = dependencyTreeTable.getSelectedModelRows(); if (rows.length == 1) { TreePath selectedPath = dependencyTreeTable.getPathForRow(rows[0]); if (selectedPath != null && selectedPath.getPathCount() == 2) { Pair<String, String> pair = (Pair<String, String>) ((MutableTreeTableNode) selectedPath .getLastPathComponent()).getUserObject(); for (Iterator<ChannelDependency> it = dependencies.iterator(); it.hasNext();) { ChannelDependency dependency = it.next(); if (StringUtils.equals(channel.getId(), dependency.getDependentId()) && StringUtils.equals(pair.getLeft(), dependency.getDependencyId())) { it.remove(); } } updateTreeTable(true, dependencies); updateAddButton(); } } } }); dependencyRemoveButton.setEnabled(false); dependentLabel = new JLabel("This channel is depended upon by:"); dependentTreeTable = new MirthTreeTable(); DefaultTreeTableModel dependentModel = new SortableTreeTableModel(); DefaultMutableTreeTableNode dependentRootNode = new DefaultMutableTreeTableNode(); dependentModel.setRoot(dependentRootNode); dependentTreeTable.setTreeTableModel(dependentModel); dependentTreeTable.setRootVisible(false); dependentTreeTable.setDoubleBuffered(true); dependentTreeTable.setDragEnabled(false); dependentTreeTable.setRowSelectionAllowed(true); dependentTreeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); dependentTreeTable.setRowHeight(UIConstants.ROW_HEIGHT); dependentTreeTable.setFocusable(true); dependentTreeTable.setOpaque(true); dependentTreeTable.setEditable(false); dependentTreeTable.setSortable(true); dependentTreeTable.putClientProperty("JTree.lineStyle", "Horizontal"); dependentTreeTable.setAutoCreateColumnsFromModel(false); dependentTreeTable.setShowGrid(true, true); dependentTreeTable.setTableHeader(null); if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) { dependentTreeTable.setHighlighters(HighlighterFactory .createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR)); } dependentTreeTable.setTreeCellRenderer(new DependencyTreeCellRenderer(dependentTreeTable)); dependentTreeTable.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent evt) { checkSelection(evt); } @Override public void mouseReleased(MouseEvent evt) { checkSelection(evt); } private void checkSelection(MouseEvent evt) { if (dependentTreeTable.rowAtPoint(new Point(evt.getX(), evt.getY())) < 0) { dependentTreeTable.clearSelection(); } } }); dependentTreeTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent evt) { if (!evt.getValueIsAdjusting()) { boolean removeEnabled = false; int[] rows = dependentTreeTable.getSelectedModelRows(); if (rows.length == 1) { TreePath selectedPath = dependentTreeTable.getPathForRow(rows[0]); if (selectedPath != null) { if (selectedPath.getPathCount() == 2) { removeEnabled = true; } } } dependentRemoveButton.setEnabled(removeEnabled); } } }); dependentScrollPane = new JScrollPane(dependentTreeTable); dependentExpandAllLabel = new JLabel("<html><u>Expand All</u></html>"); dependentExpandAllLabel.setForeground(Color.BLUE); dependentExpandAllLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); dependentExpandAllLabel.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent evt) { dependentTreeTable.expandAll(); } }); dependentCollapseAllLabel = new JLabel("<html><u>Collapse All</u></html>"); dependentCollapseAllLabel.setForeground(Color.BLUE); dependentCollapseAllLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); dependentCollapseAllLabel.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent evt) { dependentTreeTable.collapseAll(); } }); dependentAddButton = new JButton("Add"); dependentAddButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { Map<String, String> allowedChannelsMap = getAllowedChannels(false); if (MapUtils.isNotEmpty(allowedChannelsMap)) { AddDialog dialog = new AddDialog(allowedChannelsMap, false); if (dialog.wasSaved()) { for (String dependentId : dialog.getSelectedChannelIds()) { dependencies.add(new ChannelDependency(dependentId, channel.getId())); } updateTreeTable(false, dependencies); updateAddButton(); } } } }); dependentRemoveButton = new JButton("Remove"); dependentRemoveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { int[] rows = dependentTreeTable.getSelectedModelRows(); if (rows.length == 1) { TreePath selectedPath = dependentTreeTable.getPathForRow(rows[0]); if (selectedPath != null && selectedPath.getPathCount() == 2) { Pair<String, String> pair = (Pair<String, String>) ((MutableTreeTableNode) selectedPath .getLastPathComponent()).getUserObject(); for (Iterator<ChannelDependency> it = dependencies.iterator(); it.hasNext();) { ChannelDependency dependency = it.next(); if (StringUtils.equals(pair.getLeft(), dependency.getDependentId()) && StringUtils.equals(channel.getId(), dependency.getDependencyId())) { it.remove(); } } updateTreeTable(false, dependencies); updateAddButton(); } } } }); dependentRemoveButton.setEnabled(false); }