List of usage examples for java.awt Point Point
public Point(int x, int y)
From source file:com.tag.FramePreferences.java
public void restoreLocation() { Dimension size = frame.getSize(); Point location = getPreferredLocation(); if (isOffScreen(size, location)) { GraphicsConfiguration gc = frame.getGraphicsConfiguration(); Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(gc); location = new Point(insets.left, insets.top); }/* w w w. j a v a 2 s. com*/ frame.setLocation(location); }
From source file:modelibra.designer.metaneighbor.MetaNeighbor.java
public Point getNamePoint() { int x = 0;// w w w .j a v a 2 s.c om int y = 0; MetaConcept sourceConcept = getMetaSourceConcept(); MetaConcept destinationConcept = getMetaDestinationConcept(); if ((sourceConcept != null) && (destinationConcept != null)) { int x1 = getVisibleBeginPoint().x; int y1 = getVisibleBeginPoint().y; int x2 = getVisibleEndPoint().x; int y2 = getVisibleEndPoint().y; if (x1 <= x2) { x = x1 + 3 * ((x2 - x1) / 8); if (y1 <= y2) { y = y1 + 3 * ((y2 - y1) / 8); } else { y = y2 + 5 * ((y1 - y2) / 8); } } else { x = x2 + 5 * ((x1 - x2) / 8); if (y1 <= y2) { y = y1 + 3 * ((y2 - y1) / 8); } else { y = y2 + 5 * ((y1 - y2) / 8); } } } return new Point(x, y); }
From source file:it.unibas.spicygui.controllo.provider.intermediatezone.WidgetCreator.java
public Widget loadConstantInterWidget(Scene scene, LayerWidget mainLayer, LayerWidget connectionLayer, JPanel pannelloPrincipale, Point point, GraphSceneGlassPane glassPane, ISourceValue sourceValue) { CaratteristicheWidgetInterConst caratteristicheWidget = new CaratteristicheWidgetInterConst(); caratteristicheWidget.setTreeType(Costanti.INTERMEDIE); caratteristicheWidget.setFormValidation(new FormValidation(true)); //giannisk/*from w w w . java 2 s .co m*/ caratteristicheWidget.setTgdView(false); //ioannisxar if (sourceValue.getSequence() != null) caratteristicheWidget.setCostante(sourceValue.toString() + "_" + sourceValue.getSequence()); else caratteristicheWidget.setCostante(sourceValue.toString()); if (sourceValue.getType() != null) caratteristicheWidget.setType(sourceValue.getType()); ConstantWidget rootWidget = new ConstantWidget(scene, point, caratteristicheWidget); rootWidget.getActions() .addAction(ActionFactory.createEditAction(new MyEditProviderConst(caratteristicheWidget))); rootWidget.getActions().addAction(ActionFactory.createConnectAction(connectionLayer, new ActionConstantConnection(mainLayer, connectionLayer, caratteristicheWidget))); rootWidget.getActions() .addAction(ActionFactory.createPopupMenuAction(new MyPopupProviderDeleteConst(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.addConstant(rootWidget); glassPane.addConstant(barra); return rootWidget; }
From source file:fr.landel.utils.commons.CollectionUtils2Test.java
/** * Test method for//w ww .j a v a 2s.co m * {@link CollectionUtils2#transformIntoSet(java.lang.Iterable, boolean)}. */ @Test public void testTransformIntoSetIterableOfIB() { try { List<Point> points = new ArrayList<>(); points.add(new Point(1, 2)); points.add(new Point(2, 0)); points.add(null); Set<String> strPoints = CollectionUtils2.transformIntoSet(points, true); assertThat(strPoints, Matchers.containsInAnyOrder("java.awt.Point[x=2,y=0]", "java.awt.Point[x=1,y=2]", "null")); } catch (IllegalArgumentException e) { fail("The test isn't correct"); } }
From source file:net.schweerelos.parrot.CombinedParrotApp.java
private void initGUI(Properties properties) { try {/* w w w . j a va2 s . c o m*/ this.setTitle(APP_TITLE); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { for (MainViewComponent mainViewComponent : mainViews) { if (mainViewComponent instanceof ParrotStateListener) { ((ParrotStateListener) mainViewComponent).parrotExiting(); } } } }); setSize(920, 690); getContentPane().setLayout(new BorderLayout()); UserInterfaceManager uiManager = new UserInterfaceManager(properties); navigators = new ArrayList<NavigatorComponent>(4); // main view listView = uiManager.createMainViewComponent(Style.TABLE); graphView = uiManager.createMainViewComponent(Style.GRAPH); mainViews.add(listView); mainViews.add(graphView); final JTabbedPane mainPanel = new JTabbedPane(); mainPanel.add(graphView.getTitle(), graphView.asJComponent()); mainPanel.add(listView.getTitle(), listView.asJComponent()); mainPanel.setSelectedIndex(0); activeMainView = graphView; mainPanel.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { if (e.getSource() != mainPanel) { return; } int selectedIndex = mainPanel.getSelectedIndex(); if (selectedIndex == 0) { activeMainView = graphView; } else if (selectedIndex == 1) { activeMainView = listView; } else { Logger logger = Logger.getLogger(CombinedParrotApp.class); logger.warn("unknown tab index selected: " + selectedIndex); } } }); add(mainPanel, BorderLayout.CENTER); // navigators JToolBar navigatorsBar = new JToolBar(JToolBar.HORIZONTAL); navigatorsBar.setMargin(new Insets(0, 11, 0, 0)); navigatorsBar.setFloatable(false); getContentPane().add(navigatorsBar, BorderLayout.PAGE_START); // timeline NavigatorComponent timelineNavigator = uiManager.createTimelineNavigationComponent(); navigators.add(timelineNavigator); JFrame timelineFrame = new JFrame(timelineNavigator.getNavigatorName() + " " + APP_TITLE); timelineFrame.getContentPane().add(timelineNavigator.asJComponent()); timelineFrame.pack(); Point preferredLocation = new Point(0, 0); preferredFrameLocations.put(timelineFrame, preferredLocation); if (timelineNavigator.hasShowHideListener()) { timelineFrame.addComponentListener(timelineNavigator.getShowHideListener()); } timelineFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); JToggleButton timelineButton = setupNavigatorButton(timelineNavigator.getNavigatorName(), timelineNavigator.getAcceleratorKey(), timelineNavigator); navigatorsBar.add(timelineButton); // map NavigatorComponent mapNavigator = uiManager.createMapNavigationComponent(); navigators.add(mapNavigator); JFrame mapFrame = new JFrame(mapNavigator.getNavigatorName() + " " + APP_TITLE); mapFrame.getContentPane().add(mapNavigator.asJComponent()); mapFrame.pack(); preferredLocation = new Point(0, Toolkit.getDefaultToolkit().getScreenSize().height - mapFrame.getHeight()); preferredFrameLocations.put(mapFrame, preferredLocation); if (mapNavigator.hasShowHideListener()) { mapFrame.addComponentListener(mapNavigator.getShowHideListener()); } mapFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); JToggleButton mapButton = setupNavigatorButton(mapNavigator.getNavigatorName(), mapNavigator.getAcceleratorKey(), mapNavigator); navigatorsBar.add(mapButton); // search NavigatorComponent searchNavigator = uiManager.createSearchComponent(); navigators.add(searchNavigator); JFrame searchFrame = new JFrame(searchNavigator.getNavigatorName() + " " + APP_TITLE); searchFrame.getContentPane().add(searchNavigator.asJComponent()); searchFrame.pack(); preferredLocation = new Point( Toolkit.getDefaultToolkit().getScreenSize().width - searchFrame.getWidth(), 0); preferredFrameLocations.put(searchFrame, preferredLocation); if (searchNavigator.hasShowHideListener()) { searchFrame.addComponentListener(searchNavigator.getShowHideListener()); } searchFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); JToggleButton searchButton = setupNavigatorButton(searchNavigator.getNavigatorName(), searchNavigator.getAcceleratorKey(), searchNavigator); navigatorsBar.add(searchButton); // connections NavigatorComponent chainNavigator = uiManager.createChainNavigationComponent(); navigators.add(chainNavigator); if (chainNavigator instanceof PickListener) { for (MainViewComponent mainViewComponent : mainViews) { mainViewComponent.addPickListener((PickListener) chainNavigator); } } if (chainNavigator.hasShowHideListener()) { chainNavigator.asJComponent().addComponentListener(chainNavigator.getShowHideListener()); } JToggleButton connectionsButton = setupNavigatorButton(chainNavigator.getNavigatorName(), chainNavigator.getAcceleratorKey(), chainNavigator); navigatorsBar.add(connectionsButton); add(chainNavigator.asJComponent(), BorderLayout.PAGE_END); chainNavigator.asJComponent().setVisible(false); } catch (RuntimeException e) { e.printStackTrace(System.err); System.exit(1); } catch (UnknownStyleException e) { e.printStackTrace(System.err); System.exit(1); } }
From source file:net.pandoragames.far.ui.swing.FindAndReplace.java
/** * User preferences./* w w w .j ava2 s.c o m*/ */ private void configure() { logger.debug("Configuration..."); try { config = new SwingConfig(); configFactory = new FARConfigurationFactory(); configFactory.loadConfig(config); // localizer File localizerProperties = new File( this.getClass().getClassLoader().getResource("fartext.properties").toURI()); Localizer loco = new DefaultLocalizer(localizerProperties, Locale.ENGLISH); JComponent.setDefaultLocale(loco.getLocale()); config.setLocalizer(loco); } catch (Exception x) { logger.error(x.getClass().getName() + ": " + x.getMessage(), x); throw new ConfigurationException(x.getClass().getName() + ": " + x.getMessage()); } // standard component hight JButton testButton = new JButton("TEST"); config.setStandardComponentHight(testButton.getPreferredSize().height); // screen center Rectangle screen = getGraphicsConfiguration().getBounds(); config.setScreenCenter(new Point((screen.width - screen.x) / 2, (screen.height - screen.y) / 2)); }
From source file:web.diva.server.model.SomClustering.SomClustImgGenerator.java
public BufferedImage generateHeatMap(Dataset dataset, boolean clustColumn) { colorFactory = new HeatmapColorFactory(); heatMapImg = null;/*w w w. ja v a 2 s .co m*/ if (clustColumn) { heatMapImg = new BufferedImage((upperTree.getWidth() + squareW), (sideTree.getHeight()), BufferedImage.TYPE_INT_ARGB); } else { heatMapImg = new BufferedImage((dataset.getColumnIds().length * squareW + squareW), (sideTree.getHeight()), BufferedImage.TYPE_INT_ARGB); TopTreeWidth = dataset.getColumnIds().length * squareW + squareW; } Graphics g = heatMapImg.getGraphics(); g.setFont(getTableFont(12)); drawSquares(g, new Point(0, 0), null, dataset, clustColumn); return heatMapImg; }
From source file:com.theaigames.game.warlight2.MapCreator.java
/** * @param map/*from w w w . java 2 s . c om*/ * @return : the string representation of how given map's regions are connected */ private static String getNeighborsString(Map map) { String neighborsString = "setup_map neighbors"; ArrayList<Point> doneList = new ArrayList<Point>(); for (Region region : map.regions) { int id = region.getId(); String neighbors = ""; for (Region neighbor : region.getNeighbors()) { if (checkDoneList(doneList, id, neighbor.getId())) { neighbors = neighbors.concat("," + neighbor.getId()); doneList.add(new Point(id, neighbor.getId())); } } if (neighbors.length() != 0) { neighbors = neighbors.replaceFirst(",", " "); neighborsString = neighborsString.concat(" " + id + neighbors); } } return neighborsString; }
From source file:com.tag.FramePreferences.java
public Point getPreferredLocation() { Preferences prefs = getPreferences(); int def = 0;/* www .j a v a2 s.c om*/ int x = prefs.getInt(KEY_X, def); int y = prefs.getInt(KEY_Y, def); return new Point(x, y); }
From source file:com.projity.pm.graphic.graph.GraphInteractor.java
protected Cursor getProgressCursor() { if (progressCursor == null) { try {//from w ww . ja v a2s .c o m progressCursor = Toolkit.getDefaultToolkit().createCustomCursor( IconManager.getImage("gantt.progress.cursor"), new Point(15, 5), "ProgressCursor"); } catch (Exception e) { progressCursor = new Cursor(Cursor.HAND_CURSOR); } } return progressCursor; }