List of usage examples for java.awt Point Point
public Point(int x, int y)
From source file:com.igormaznitsa.mindmap.swing.panel.MindMapPanel.java
public MindMapPanel(final MindMapPanelController controller) { super(null);// www .j av a 2s. co m this.textEditorPanel.setLayout(new BorderLayout(0, 0)); this.controller = controller; this.config = new MindMapPanelConfig(controller.provideConfigForMindMapPanel(this), false); this.textEditor.setMargin(new Insets(5, 5, 5, 5)); this.textEditor.setBorder(BorderFactory.createEtchedBorder()); this.textEditor.setTabSize(4); this.textEditor.addKeyListener(new KeyAdapter() { @Override public void keyPressed(final KeyEvent e) { switch (e.getKeyCode()) { case KeyEvent.VK_ENTER: { e.consume(); } break; case KeyEvent.VK_TAB: { if ((e.getModifiers() & ALL_SUPPORTED_MODIFIERS) == 0) { e.consume(); final Topic edited = elementUnderEdit.getModel(); final int[] topicPosition = edited.getPositionPath(); endEdit(true); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { final Topic theTopic = model.findForPositionPath(topicPosition); if (theTopic != null) { makeNewChildAndStartEdit(theTopic, null); } } }); } } break; default: break; } } @Override public void keyTyped(final KeyEvent e) { if (e.getKeyChar() == KeyEvent.VK_ENTER) { if ((e.getModifiers() & ALL_SUPPORTED_MODIFIERS) == 0) { e.consume(); endEdit(true); } else { e.consume(); textEditor.insert("\n", textEditor.getCaretPosition()); //NOI18N } } } @Override public void keyReleased(final KeyEvent e) { if (config.isKeyEvent(MindMapPanelConfig.KEY_CANCEL_EDIT, e)) { e.consume(); final Topic edited = elementUnderEdit == null ? null : elementUnderEdit.getModel(); endEdit(false); if (edited != null && edited.canBeLost()) { deleteTopics(edited); if (pathToPrevTopicBeforeEdit != null) { final int[] path = pathToPrevTopicBeforeEdit; pathToPrevTopicBeforeEdit = null; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { final Topic topic = model.findForPositionPath(path); if (topic != null) { select(topic, false); } } }); } } } } }); this.textEditor.getDocument().addDocumentListener(new DocumentListener() { private void updateEditorPanelSize(final Dimension newSize) { final Dimension editorPanelMinSize = textEditorPanel.getMinimumSize(); final Dimension newDimension = new Dimension(Math.max(editorPanelMinSize.width, newSize.width), Math.max(editorPanelMinSize.height, newSize.height)); textEditorPanel.setSize(newDimension); textEditorPanel.repaint(); } @Override public void insertUpdate(DocumentEvent e) { updateEditorPanelSize(textEditor.getPreferredSize()); } @Override public void removeUpdate(DocumentEvent e) { updateEditorPanelSize(textEditor.getPreferredSize()); } @Override public void changedUpdate(DocumentEvent e) { updateEditorPanelSize(textEditor.getPreferredSize()); } }); this.textEditorPanel.add(this.textEditor, BorderLayout.CENTER); super.setOpaque(true); final KeyAdapter keyAdapter = new KeyAdapter() { @Override public void keyTyped(KeyEvent e) { if (config.isKeyEvent(MindMapPanelConfig.KEY_ADD_CHILD_AND_START_EDIT, e)) { if (!selectedTopics.isEmpty()) { makeNewChildAndStartEdit(selectedTopics.get(0), null); } } else if (config.isKeyEvent(MindMapPanelConfig.KEY_ADD_SIBLING_AND_START_EDIT, e)) { if (!hasActiveEditor() && hasOnlyTopicSelected()) { final Topic baseTopic = selectedTopics.get(0); makeNewChildAndStartEdit(baseTopic.getParent() == null ? baseTopic : baseTopic.getParent(), baseTopic); } } else if (config.isKeyEvent(MindMapPanelConfig.KEY_FOCUS_ROOT_OR_START_EDIT, e)) { if (!hasSelectedTopics()) { select(getModel().getRoot(), false); } else if (hasOnlyTopicSelected()) { startEdit((AbstractElement) selectedTopics.get(0).getPayload()); } } } @Override public void keyReleased(final KeyEvent e) { if (config.isKeyEvent(MindMapPanelConfig.KEY_DELETE_TOPIC, e)) { e.consume(); deleteSelectedTopics(); } else if (config.isKeyEventDetected(e, MindMapPanelConfig.KEY_FOCUS_MOVE_LEFT, MindMapPanelConfig.KEY_FOCUS_MOVE_RIGHT, MindMapPanelConfig.KEY_FOCUS_MOVE_UP, MindMapPanelConfig.KEY_FOCUS_MOVE_DOWN)) { e.consume(); processMoveFocusByKey(e); } } }; this.setFocusTraversalKeysEnabled(false); final MindMapPanel theInstance = this; final MouseAdapter adapter = new MouseAdapter() { @Override public void mouseEntered(final MouseEvent e) { setCursor(Cursor.getDefaultCursor()); } @Override public void mouseMoved(final MouseEvent e) { if (!controller.isMouseMoveProcessingAllowed(theInstance)) { return; } final AbstractElement element = findTopicUnderPoint(e.getPoint()); if (element == null) { setCursor(Cursor.getDefaultCursor()); setToolTipText(null); } else { final ElementPart part = element.findPartForPoint(e.getPoint()); setCursor(part == ElementPart.ICONS || part == ElementPart.COLLAPSATOR ? Cursor.getPredefinedCursor(Cursor.HAND_CURSOR) : Cursor.getDefaultCursor()); if (part == ElementPart.ICONS) { final Extra<?> extra = element.getIconBlock().findExtraForPoint( e.getPoint().getX() - element.getBounds().getX(), e.getPoint().getY() - element.getBounds().getY()); if (extra != null) { setToolTipText(makeHtmlTooltipForExtra(extra)); } else { setToolTipText(null); } } else { setToolTipText(null); } } } @Override public void mousePressed(final MouseEvent e) { if (!controller.isMouseClickProcessingAllowed(theInstance)) { return; } try { if (e.isPopupTrigger()) { mouseDragSelection = null; MindMap theMap = model; AbstractElement element = null; if (theMap != null) { element = findTopicUnderPoint(e.getPoint()); } processPopUp(e.getPoint(), element); e.consume(); } else { endEdit(elementUnderEdit != null); mouseDragSelection = null; } } catch (Exception ex) { LOGGER.error("Error during mousePressed()", ex); } } @Override public void mouseReleased(final MouseEvent e) { if (!controller.isMouseClickProcessingAllowed(theInstance)) { return; } try { if (draggedElement != null) { draggedElement.updatePosition(e.getPoint()); if (endDragOfElement(draggedElement, destinationElement)) { updateView(true); } } else if (mouseDragSelection != null) { final List<Topic> covered = mouseDragSelection.getAllSelectedElements(model); if (e.isShiftDown()) { for (final Topic m : covered) { select(m, false); } } else if (e.isControlDown()) { for (final Topic m : covered) { select(m, true); } } else { removeAllSelection(); for (final Topic m : covered) { select(m, false); } } } else if (e.isPopupTrigger()) { mouseDragSelection = null; MindMap theMap = model; AbstractElement element = null; if (theMap != null) { element = findTopicUnderPoint(e.getPoint()); } processPopUp(e.getPoint(), element); e.consume(); } } catch (Exception ex) { LOGGER.error("Error during mouseReleased()", ex); } finally { mouseDragSelection = null; draggedElement = null; destinationElement = null; repaint(); } } @Override public void mouseDragged(final MouseEvent e) { if (!controller.isMouseMoveProcessingAllowed(theInstance)) { return; } scrollRectToVisible(new Rectangle(e.getX(), e.getY(), 1, 1)); if (!popupMenuActive) { if (draggedElement == null && mouseDragSelection == null) { final AbstractElement elementUnderMouse = findTopicUnderPoint(e.getPoint()); if (elementUnderMouse == null) { MindMap theMap = model; if (theMap != null) { final AbstractElement element = findTopicUnderPoint(e.getPoint()); if (controller.isSelectionAllowed(theInstance) && element == null) { mouseDragSelection = new MouseSelectedArea(e.getPoint()); } } } else if (controller.isElementDragAllowed(theInstance)) { if (elementUnderMouse.isMoveable()) { selectedTopics.clear(); final Point mouseOffset = new Point( (int) Math .round(e.getPoint().getX() - elementUnderMouse.getBounds().getX()), (int) Math .round(e.getPoint().getY() - elementUnderMouse.getBounds().getY())); draggedElement = new DraggedElement(elementUnderMouse, config, mouseOffset, e.isControlDown() || e.isMetaDown() ? DraggedElement.Modifier.MAKE_JUMP : DraggedElement.Modifier.NONE); draggedElement.updatePosition(e.getPoint()); findDestinationElementForDragged(); } else { draggedElement = null; } repaint(); } } else if (mouseDragSelection != null) { if (controller.isSelectionAllowed(theInstance)) { mouseDragSelection.update(e); } else { mouseDragSelection = null; } repaint(); } else if (draggedElement != null) { if (controller.isElementDragAllowed(theInstance)) { draggedElement.updatePosition(e.getPoint()); findDestinationElementForDragged(); } else { draggedElement = null; } repaint(); } } else { mouseDragSelection = null; } } @Override public void mouseWheelMoved(final MouseWheelEvent e) { if (controller.isMouseWheelProcessingAllowed(theInstance)) { mouseDragSelection = null; draggedElement = null; final MindMapPanelConfig theConfig = config; if (!e.isConsumed() && (theConfig != null && ((e.getModifiers() & theConfig.getScaleModifiers()) == theConfig .getScaleModifiers()))) { endEdit(elementUnderEdit != null); setScale( Math.max(0.3d, Math.min(getScale() + (SCALE_STEP * -e.getWheelRotation()), 10.0d))); updateView(false); e.consume(); } else { sendToParent(e); } } } @Override public void mouseClicked(final MouseEvent e) { if (!controller.isMouseClickProcessingAllowed(theInstance)) { return; } mouseDragSelection = null; draggedElement = null; MindMap theMap = model; AbstractElement element = null; if (theMap != null) { element = findTopicUnderPoint(e.getPoint()); } if (element != null) { final ElementPart part = element.findPartForPoint(e.getPoint()); if (part == ElementPart.COLLAPSATOR) { removeAllSelection(); if (element.isCollapsed()) { ((AbstractCollapsableElement) element).setCollapse(false); if ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0) { ((AbstractCollapsableElement) element).collapseAllFirstLevelChildren(); } } else { ((AbstractCollapsableElement) element).setCollapse(true); } invalidate(); fireNotificationMindMapChanged(); repaint(); } else if (part != ElementPart.ICONS && e.getClickCount() > 1) { startEdit(element); } else if (part == ElementPart.ICONS) { final Extra<?> extra = element.getIconBlock().findExtraForPoint( e.getPoint().getX() - element.getBounds().getX(), e.getPoint().getY() - element.getBounds().getY()); if (extra != null) { fireNotificationClickOnExtra(element.getModel(), e.getClickCount(), extra); } } else { if (!e.isControlDown()) { // only removeAllSelection(); select(element.getModel(), false); } else // group if (selectedTopics.isEmpty()) { select(element.getModel(), false); } else { select(element.getModel(), true); } } } } }; addMouseWheelListener(adapter); addMouseListener(adapter); addMouseMotionListener(adapter); addKeyListener(keyAdapter); this.textEditorPanel.setVisible(false); this.add(this.textEditorPanel); }
From source file:jhplot.HPlotChart.java
public void drawToGraphics2D(Graphics2D g, int width, int height) { // self.chartCoordsMap = {} #Maps a chart to its raw screen coords, used // for converting coords g.setColor(Color.white);//from www. j a v a 2s.c o m g.fillRect(0, 0, width, height); // // int boxWidth = width / this.chartarray[0].length; // int boxHeight = height / this.chartarray.length; int cols = 1; int rows = 1; int boxWidth = width / cols; int boxHeight = height / rows; // // # print "boxWidth ", boxWidth // # print "boxHeight ", boxHeight // for (int row = 0; row < chartarray.length; row++) int currentChartIndex = 0; for (int i2 = 0; i2 < rows; i2++) { for (int i1 = 0; i1 < cols; i1++) { currentChartIndex++; if (chart != null) { int rowsUsed = 1; int colsUsed = 1; int chartX = boxWidth * i1; int chartY = boxHeight * i2; int chartwidth = boxWidth; int chartheight = boxHeight; // #Get Horizontalspace // for (int c = col; c > -1; c--) // { // // for c in range(col, -1, -1): // // if self.chartArray[row][c] == None: // if(this.chartarray[row][c] == null) // rowsUsed++; // // // rowsUsed = rowsUsed + 1 // // #print "adding row" // } chartwidth = boxWidth * rowsUsed; chartheight = boxHeight; chartX = chartX - (rowsUsed - 1) * boxWidth; // // # chart.configureDomainAxes() // # chart.configureRangeAxes() // // #Testing axes ranges not updated // from org.jfree.chart.event import PlotChangeEvent // chart[i1][i2].plotChanged(new // PlotChangeEvent(chart[i1][i2].getXYPlot())); chart.plotChanged(new PlotChangeEvent(chart.getPlot())); // ChartRenderingInfo info = new ChartRenderingInfo(); // chart.draw(g, new java.awt.Rectangle(chartX, chartY, chartwidth, chartheight), new Point(chartX, chartY), info); // self.chartToInfoMap[chart] = info // // self.chartCoordsMap[chart] = [chartX ,chartY,chartwidth, // chartheight] } } } }
From source file:com.sec.ose.osi.ui.frm.main.identification.codematch.JPanCodeMatchMain.java
private void setCurPosition() { if (totalLine != 0) { log.debug("setCurPosition selectSnippetNum : " + selectSnippetNum); JLabel jLabelPosition = null; int curPosY = 0; if (totalLine > 0 && getSimilarSnippets().size() > 0) { curPosY = getSimilarSnippets().get(selectSnippetNum).getLeftSnippet().getFirstLine() * getJSplitPaneSourceCode().getHeight() / totalLine; }//from www. j av a2 s. c om jLabelPosition = new JLabel(); jLabelPosition.setPreferredSize(new Dimension(15, 15)); jLabelPosition.setLocation(new Point(35, curPosY)); jLabelPosition.setSize(new Dimension(15, 15)); jLabelPosition.setText(""); getJPanMatchedSourceViewLeft().getJPanelNavigator().add(jLabelPosition, null); } }
From source file:it.unibas.spicygui.controllo.provider.intermediatezone.WidgetCreator.java
public Widget createConstantWidget(Scene scene, LayerWidget mainLayer, LayerWidget connectionLayer, Point point, GraphSceneGlassPane glassPane, Scenario scenario) { if (alrearyExistsConstantCompositionWidget(glassPane, scenario)) { return null; }//from w w w. j a v a 2 s . co m ConstantCompositionWidget rootWidget = new ConstantCompositionWidget(scene, point, scenario.getImageNumber()); CaratteristicheWidgetConstantComposition caratteristicheWidget = new CaratteristicheWidgetConstantComposition( new MutableMappingTask(scenario.getMappingTask()), scenario); caratteristicheWidget.setTreeType(Costanti.COMPOSITION_TYPE); // rootWidget.getActions().addAction(ActionFactory.createEditAction(new MyEditProviderFunction(caratteristicheWidget))); rootWidget.getActions().addAction(ActionFactory.createConnectAction(connectionLayer, new ActionConstantCompositionConnection(connectionLayer, mainLayer, caratteristicheWidget))); rootWidget.getActions().addAction(ActionFactory .createPopupMenuAction(new MyPopupProviderWidgetConstantComposition(glassPane.getScene()))); // 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.addConstant(rootWidget); glassPane.addConstant(barra); scene.validate(); // scenario.setInComposition(true); return rootWidget; }
From source file:at.tuwien.ifs.somtoolbox.apps.viewer.MapPNode.java
/** Calculates the absolute position of an input on the {@link MapPNode}. */ private Point getPointLocation(String name) { Unit unitBegin = gsom.getLayer().getUnitForDatum(name); if (unitBegin != null) { GeneralUnitPNode generalUnitPNode = units[unitBegin.getXPos()][unitBegin.getYPos()]; Point offset = generalUnitPNode.getPostion(); int inputIndexBegin = unitBegin.getInputIndex(name); Point point = generalUnitPNode.getLocations()[inputIndexBegin]; return new Point(point.x + offset.x + InputPNode.WIDTH_2, point.y + offset.y + InputPNode.HEIGHT_2); } else {//w ww. j a v a2 s.c o m System.out.println("did not find datum " + name); return null; } }
From source file:net.sf.maltcms.chromaui.project.spi.descriptors.CachingChromatogram2D.java
@Override public Point getPointFor(int i) { init();//from w w w .j a v a2 s. c o m IScan2D scan2d = getScan(i); return new Point(scan2d.getFirstColumnScanIndex(), scan2d.getSecondColumnScanIndex()); }
From source file:net.sf.maltcms.chromaui.project.spi.descriptors.CachingChromatogram2D.java
@Override public Point getPointFor(double d) { init();/*from w ww . j av a 2s . c o m*/ IScan2D scan2d = getScan(getIndexFor(d)); return new Point(scan2d.getFirstColumnScanIndex(), scan2d.getSecondColumnScanIndex()); }
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 has the * same sources as the original table and does not use the table copied from * as its source. Note that this is testing copy, not reverse engineering. *///from w w w . j a v a2s. com public void testPasteCopyTable() 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); 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); assertEquals(sourceCol, copy.getColumnByName("NewCol1").getSourceColumn()); assertEquals(sourceCol, copy.getColumnByName("NewCol2").getSourceColumn()); }
From source file:blusunrize.immersiveengineering.client.render.TileRenderAutoWorkbench.java
public static BlueprintLines getBlueprintDrawable(ItemStack stack, World world) { if (stack.isEmpty()) return null; EntityPlayer player = ClientUtils.mc().player; ArrayList<BufferedImage> images = new ArrayList<>(); try {/* www.j a va 2 s . com*/ IBakedModel ibakedmodel = ClientUtils.mc().getRenderItem().getItemModelWithOverrides(stack, world, player); HashSet<String> textures = new HashSet(); Collection<BakedQuad> quads = ibakedmodel.getQuads(null, null, 0); for (BakedQuad quad : quads) if (quad != null && quad.getSprite() != null) textures.add(quad.getSprite().getIconName()); for (String s : textures) { ResourceLocation rl = new ResourceLocation(s); rl = new ResourceLocation(rl.getNamespace(), String.format("%s/%s%s", "textures", rl.getPath(), ".png")); IResource resource = ClientUtils.mc().getResourceManager().getResource(rl); BufferedImage bufferedImage = TextureUtil.readBufferedImage(resource.getInputStream()); if (bufferedImage != null) images.add(bufferedImage); } } catch (Exception e) { } if (images.isEmpty()) return null; ArrayList<Pair<TexturePoint, TexturePoint>> lines = new ArrayList(); HashSet testSet = new HashSet(); HashMultimap<Integer, TexturePoint> area = HashMultimap.create(); int wMax = 0; for (BufferedImage bufferedImage : images) { Set<Pair<TexturePoint, TexturePoint>> temp_lines = new HashSet<>(); int w = bufferedImage.getWidth(); int h = bufferedImage.getHeight(); if (h > w) h = w; if (w > wMax) wMax = w; for (int hh = 0; hh < h; hh++) for (int ww = 0; ww < w; ww++) { int argb = bufferedImage.getRGB(ww, hh); float r = (argb >> 16 & 255) / 255f; float g = (argb >> 8 & 255) / 255f; float b = (argb & 255) / 255f; float intesity = (r + b + g) / 3f; int alpha = (argb >> 24) & 255; if (alpha > 0) { boolean added = false; //Check colour sets for similar colour to shade it later TexturePoint tp = new TexturePoint(ww, hh, w); if (!testSet.contains(tp)) { for (Integer key : area.keySet()) { for (TexturePoint p : area.get(key)) { float mod = w / (float) p.scale; int pColour = bufferedImage.getRGB((int) (p.x * mod), (int) (p.y * mod)); float dR = (r - (pColour >> 16 & 255) / 255f); float dG = (g - (pColour >> 8 & 255) / 255f); float dB = (b - (pColour & 255) / 255f); double delta = Math.sqrt(dR * dR + dG * dG + dB * dB); if (delta < .25) { area.put(key, tp); added = true; break; } } if (added) break; } if (!added) area.put(argb, tp); testSet.add(tp); } //Compare to direct neighbour for (int i = 0; i < 4; i++) { int xx = (i == 0 ? -1 : i == 1 ? 1 : 0); int yy = (i == 2 ? -1 : i == 3 ? 1 : 0); int u = ww + xx; int v = hh + yy; int neighbour = 0; float delta = 1; boolean notTransparent = false; if (u >= 0 && u < w && v >= 0 && v < h) { neighbour = bufferedImage.getRGB(u, v); notTransparent = ((neighbour >> 24) & 255) > 0; if (notTransparent) { float neighbourIntesity = ((neighbour >> 16 & 255) + (neighbour >> 8 & 255) + (neighbour & 255)) / 765f; float intesityDelta = Math.max(0, Math.min(1, Math.abs(intesity - neighbourIntesity))); float rDelta = Math.max(0, Math.min(1, Math.abs(r - (neighbour >> 16 & 255) / 255f))); float gDelta = Math.max(0, Math.min(1, Math.abs(g - (neighbour >> 8 & 255) / 255f))); float bDelta = Math.max(0, Math.min(1, Math.abs(b - (neighbour & 255) / 255f))); delta = Math.max(intesityDelta, Math.max(rDelta, Math.max(gDelta, bDelta))); delta = delta < .25 ? 0 : delta > .4 ? 1 : delta; } } if (delta > 0) { Pair<TexturePoint, TexturePoint> l = Pair.of( new TexturePoint(ww + (i == 0 ? 0 : i == 1 ? 1 : 0), hh + (i == 2 ? 0 : i == 3 ? 1 : 0), w), new TexturePoint(ww + (i == 0 ? 0 : i == 1 ? 1 : 1), hh + (i == 2 ? 0 : i == 3 ? 1 : 1), w)); temp_lines.add(l); } } } } lines.addAll(temp_lines); } ArrayList<Integer> lumiSort = new ArrayList<>(area.keySet()); Collections.sort(lumiSort, (rgb1, rgb2) -> Double.compare(getLuminance(rgb1), getLuminance(rgb2))); HashMultimap<ShadeStyle, Point> complete_areaMap = HashMultimap.create(); int lineNumber = 2; int lineStyle = 0; for (Integer i : lumiSort) { complete_areaMap.putAll(new ShadeStyle(lineNumber, lineStyle), area.get(i)); ++lineStyle; lineStyle %= 3; if (lineStyle == 0) lineNumber += 1; } Set<Pair<Point, Point>> complete_lines = new HashSet<>(); for (Pair<TexturePoint, TexturePoint> line : lines) { TexturePoint p1 = line.getKey(); TexturePoint p2 = line.getValue(); complete_lines.add(Pair.of( new Point((int) (p1.x / (float) p1.scale * wMax), (int) (p1.y / (float) p1.scale * wMax)), new Point((int) (p2.x / (float) p2.scale * wMax), (int) (p2.y / (float) p2.scale * wMax)))); } return new BlueprintLines(wMax, complete_lines, complete_areaMap); }
From source file:com.floreantpos.jasperreport.swing.JRViewerPanel.java
void pnlLinksMouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_pnlLinksMouseDragged // Add your handling code here: Container container = pnlInScroll.getParent(); if (container instanceof JViewport) { JViewport viewport = (JViewport) container; Point point = viewport.getViewPosition(); int newX = point.x - (evt.getX() - downX); int newY = point.y - (evt.getY() - downY); int maxX = pnlInScroll.getWidth() - viewport.getWidth(); int maxY = pnlInScroll.getHeight() - viewport.getHeight(); if (newX < 0) { newX = 0;//from w w w. ja v a 2 s. c o m } if (newX > maxX) { newX = maxX; } if (newY < 0) { newY = 0; } if (newY > maxY) { newY = maxY; } viewport.setViewPosition(new Point(newX, newY)); } }