Java Code Examples for java.awt.Point

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project addis, under directory /application/src/main/java/org/drugis/addis/gui/builder/.

Source file: LyndOBrienView.java

  36 
vote

public void mouseDragged(MouseEvent e){
  Point point=e.getPoint();
  Point2D.Double chartXY=convertToChartCoordinates(point);
  if ((chartXY.x > 0 && chartXY.y > 0) || (chartXY.x < 0 && chartXY.y < 0)) {
    double mu=chartXY.y / chartXY.x;
    drawMuLine(getChart().getXYPlot(),mu);
  }
}
 

Example 2

From project Chess_1, under directory /src/chess/gui/.

Source file: GridPanel.java

  34 
vote

/** 
 * Draws a square that marks the current location.
 * @param g2 the graphics context
 */
private void drawCurrentLocation(Graphics2D g2){
  if ("hide".equals(System.getProperty("chess.gui.selection")))   return;
  if (currentLocation != null) {
    Point p=pointForLocation(currentLocation);
    g2.drawRect(p.x - cellSize / 2 - 2,p.y - cellSize / 2 - 2,cellSize + 3,cellSize + 3);
  }
}
 

Example 3

From project Agot-Java, under directory /src/main/java/got/ui/.

Source file: DrawManager.java

  32 
vote

private void drawAction(TerritoryInfo ti){
  Point p=ti.getOrderP();
  if (!ti.getAction().equals(Action.NONE)) {
    graphics.drawImage(node.getImageLoader().getActionImages().get(ti.getAction()),p.x,p.y,null);
  }
}
 

Example 4

From project Aion-Extreme, under directory /AE-go_GameServer/src/com/aionemu/gameserver/model/geometry/.

Source file: AbstractArea.java

  32 
vote

/** 
 * {@inheritDoc}
 */
@Override public Point3D getClosestPoint(int x,int y,int z){
  Point closest2d=getClosestPoint(x,y);
  int zCoord;
  if (isInsideZ(z)) {
    zCoord=z;
  }
 else   if (z < getMinZ()) {
    zCoord=getMinZ();
  }
 else {
    zCoord=getMaxZ();
  }
  return new Point3D(closest2d.x,closest2d.y,zCoord);
}
 

Example 5

From project Battlepath, under directory /src/engine/.

Source file: Field.java

  32 
vote

/** 
 * Creates a circle of value 1 tiles in a field
 * @param pos world position of the circle
 * @param r radius of the circle
 */
public void createCircle(Vector2D pos,double r){
  Point topleft=tileIndexAt(new Vector2D(pos.x - r,pos.y - r));
  Point bottomright=tileIndexAt(new Vector2D(pos.x + r,pos.y + r));
  clamp(topleft);
  clamp(bottomright);
  for (int x=topleft.x; x < bottomright.x; x++) {
    for (int y=topleft.y; y < bottomright.y; y++) {
      Random rand=new Random();
      if (pos.distance(getWorldPos(new Point(x,y))) < r)       tiles[x][y].setValue(1);
    }
  }
}
 

Example 6

From project BMach, under directory /src/jsyntaxpane/actions/.

Source file: ActionUtils.java

  32 
vote

/** 
 * Get the closest position within the document of the component that has given line and column.
 * @param editor
 * @param line the first being 1
 * @param column the first being 1
 * @return the closest positon for the text component at given line andcolumn
 */
public static int getDocumentPosition(JTextComponent editor,int line,int column){
  int lineHeight=editor.getFontMetrics(editor.getFont()).getHeight();
  int charWidth=editor.getFontMetrics(editor.getFont()).charWidth('m');
  int y=line * lineHeight;
  int x=column * charWidth;
  Point pt=new Point(x,y);
  int pos=editor.viewToModel(pt);
  return pos;
}
 

Example 7

From project ceres, under directory /ceres-glayer/src/main/java/com/bc/ceres/glayer/tools/.

Source file: Tools.java

  32 
vote

@Override public void mouseReleased(final MouseEvent mouseEvent){
  if (mouseEvent.isPopupTrigger()) {
    final Point point=mouseEvent.getPoint();
    SwingUtilities.convertPointToScreen(point,layerCanvas);
    sliderPopUp.show(point);
  }
 else {
    sliderPopUp.hide();
  }
}
 

Example 8

From project Clotho-Core, under directory /ClothoApps/SeqAnalyzer/src/org/clothocad/algorithm/seqanalyzer/sequencing/.

Source file: seqReport.java

  32 
vote

public void mouseEntered(MouseEvent e){
  Point p=e.getPoint();
  for (  Shape s : regions) {
    if (s.contains(p)) {
      System.out.println("You entered " + s.toString());
    }
  }
}
 

Example 9

From project codjo-segmentation, under directory /codjo-segmentation-gui/src/main/java/net/codjo/segmentation/gui/settings/.

Source file: SleeveTerminalElementListener.java

  32 
vote

private void initPopUpMenu(JTree tree,MouseEvent event){
  if (popUpMenu == null) {
    popUpMenu=new TerminalElementContextualMenu();
    popUpMenu.setInvoker(tree);
  }
  Point invokerOrigin=tree.getLocationOnScreen();
  popUpMenu.setLocation(invokerOrigin.x + event.getX(),invokerOrigin.y + event.getY());
  popUpMenu.setVisible(true);
}
 

Example 10

From project fastjson, under directory /src/test/java/com/alibaba/json/bvt/.

Source file: PointTest.java

  32 
vote

public void test_color() throws Exception {
  JSONSerializer serializer=new JSONSerializer();
  Assert.assertEquals(PointSerializer.class,serializer.getObjectWriter(Point.class).getClass());
  Point point=new Point(3,4);
  String text=JSON.toJSONString(point);
  Point point2=JSON.parseObject(text,Point.class);
  Assert.assertEquals(point,point2);
}
 

Example 11

From project fitnesse, under directory /src/fit/decorator/util/.

Source file: PointDataType.java

  32 
vote

protected String addTo(String originalValue,Object value,int numberofTime){
  Point originalPoint=ClassDelegatePointParser.parse(originalValue);
  Point pointToBeAdded=(Point)(value);
  for (int i=0; i < numberofTime; ++i) {
    originalPoint.translate(pointToBeAdded.x,pointToBeAdded.y);
  }
  return "(" + originalPoint.x + ","+ originalPoint.y+ ")";
}
 

Example 12

From project flyingsaucer, under directory /flying-saucer-core/src/main/java/org/xhtmlrenderer/layout/.

Source file: FloatManager.java

  32 
vote

private void save(BlockBox current,Layer layer,BlockFormattingContext bfc,int direction){
  Point p=bfc.getOffset();
  getFloats(direction).add(new BoxOffset(current,p.x,p.y));
  layer.addFloat(current,bfc);
  current.getFloatedBoxData().setManager(this);
  current.calcCanvasLocation();
  current.calcChildLocations();
}
 

Example 13

From project formic, under directory /src/java/net/java/swingfx/waitwithstyle/.

Source file: SingleComponentInfiniteProgress.java

  32 
vote

private void makeSnapshot() throws AWTException {
  final Rectangle bounds=getBounds();
  final Point upperLeft=new Point(bounds.x,bounds.y);
  SwingUtilities.convertPointToScreen(upperLeft,this);
  final Rectangle screenRect=new Rectangle(upperLeft.x,upperLeft.y,bounds.width,bounds.height);
  Insets insets=getInsets();
  screenRect.x+=insets.left;
  screenRect.y+=insets.top;
  screenRect.width-=insets.left + insets.right;
  screenRect.height-=insets.top + insets.bottom;
  imageBuf=new Robot().createScreenCapture(screenRect);
}
 

Example 14

From project freemind, under directory /freemind/accessories/plugins/time/.

Source file: TimeList.java

  32 
vote

public void mouseClicked(MouseEvent e){
  if (e.getClickCount() == 2) {
    Point p=e.getPoint();
    int row=timeTable.rowAtPoint(p);
    gotoNodesAndClose(row,new int[]{row});
  }
}
 

Example 15

From project beanmill_1, under directory /src/main/java/com/traxel/lumbermill/filter/.

Source file: TreeControl.java

  31 
vote

@Override public void mouseClicked(final MouseEvent e){
  final TreePath[] paths;
  final Collection nodes;
  Node node;
  final List actions;
  final Point location;
  POPUP.setVisible(false);
  if (MouseEvent.BUTTON3 == e.getButton()) {
    final TreePath path=TREE_VIEW.getPathForLocation(e.getX(),e.getY());
    TREE_VIEW.setSelectionPath(path);
    paths=TREE_VIEW.getSelectionPaths();
    if ((paths == null) || (paths.length == 0)) {
      return;
    }
    nodes=new ArrayList();
    for (int i=0; i < paths.length; i++) {
      node=(Node)paths[i].getLastPathComponent();
      nodes.add(node);
    }
    actions=SeverityAction.getActions(nodes);
    location=getScreenLocation();
    final Point locP=TREE_PANEL.getLocationOnScreen();
    showPopup(actions,(int)(e.getX() + locP.getX()),(int)(e.getY() + locP.getY() + 5));
  }
}
 

Example 16

From project BioMAV, under directory /Behavior/src/nl/ru/ai/projects/parrot/tools/.

Source file: TwitterAccess.java

  31 
vote

/** 
 * Returns a RenderedImage object from a byte array
 * @param cameraOutput The camera output to transform into a RenderedImage
 * @return The RenderedImage that resulted from the camera output
 */
private RenderedImage getImageFromCamera(byte[] cameraOutput){
  BufferedImage image=new BufferedImage(VideoPollInterface.FRONT_VIDEO_FRAME_WIDTH,VideoPollInterface.FRONT_VIDEO_FRAME_HEIGHT,BufferedImage.TYPE_3BYTE_BGR);
  if (cameraOutput != null) {
    WritableRaster raster=Raster.createBandedRaster(DataBuffer.TYPE_BYTE,VideoPollInterface.FRONT_VIDEO_FRAME_WIDTH,VideoPollInterface.FRONT_VIDEO_FRAME_HEIGHT,3,new Point(0,0));
    raster.setDataElements(0,0,VideoPollInterface.FRONT_VIDEO_FRAME_WIDTH,VideoPollInterface.FRONT_VIDEO_FRAME_HEIGHT,cameraOutput);
    image.setData(raster);
  }
  return image;
}
 

Example 17

From project codjo-data-process, under directory /codjo-data-process-gui/src/main/java/net/codjo/dataprocess/gui/launcher/.

Source file: NewExecutionListLauncherWindow.java

  31 
vote

@Override public void mousePressed(MouseEvent evt){
  if (SwingUtilities.isRightMouseButton(evt)) {
    trtList.setSelectedIndex(trtList.locationToIndex(new Point(evt.getPoint())));
    if (evt.isPopupTrigger()) {
      popupMenuTrtList.show(evt.getComponent(),evt.getX(),evt.getY());
    }
  }
}
 

Example 18

From project contribution_eevolution_smart_browser, under directory /client/src/org/compiere/apps/.

Source file: APanel.java

  31 
vote

/** 
 * Toggle History
 */
private void cmd_history(){
  log.info("");
  if (m_mWorkbench.getMWindow(getWindowIndex()).isTransaction()) {
    if (m_curTab.needSave(true,true) && !cmd_save(false))     return;
    Point pt=new Point(0,aHistory.getButton().getBounds().height);
    SwingUtilities.convertPointToScreen(pt,aHistory.getButton());
    VOnlyCurrentDays ocd=new VOnlyCurrentDays(Env.getFrame(this),pt);
    if (!ocd.isCancel()) {
      m_onlyCurrentDays=ocd.getCurrentDays();
      if (m_onlyCurrentDays == 1) {
        m_onlyCurrentRows=true;
        m_onlyCurrentDays=0;
      }
 else       m_onlyCurrentRows=false;
      m_curTab.setQuery(null);
      MRole role=MRole.getDefault();
      int maxRows=role.getMaxQueryRecords();
      log.config("OnlyCurrent=" + m_onlyCurrentRows + ", Days="+ m_onlyCurrentDays+ ", MaxRows="+ maxRows);
      m_curGC.query(m_onlyCurrentRows,m_onlyCurrentDays,maxRows);
    }
 else {
      if (isFirstTab())       aHistory.setPressed(!m_curTab.isOnlyCurrentRows());
    }
  }
}
 

Example 19

From project dawn-common, under directory /org.dawb.hdf5/src/ncsa/hdf/view/.

Source file: Chart.java

  31 
vote

/** 
 * Creates and layouts GUI components.
 */
protected void createUI(){
  Window owner=getOwner();
  JPanel contentPane=(JPanel)getContentPane();
  contentPane.setLayout(new BorderLayout(5,5));
  contentPane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
  int w=640 + (ViewProperties.getFontSize() - 12) * 15;
  int h=400 + (ViewProperties.getFontSize() - 12) * 10;
  contentPane.setPreferredSize(new Dimension(w,h));
  contentPane.add(chartP,BorderLayout.CENTER);
  JButton button=new JButton("Close");
  button.addActionListener(this);
  button.setActionCommand("Close");
  JPanel tmp=new JPanel();
  tmp.add(button);
  contentPane.add(tmp,BorderLayout.SOUTH);
  Point l=owner.getLocation();
  l.x+=220;
  l.y+=100;
  setLocation(l);
  pack();
}
 

Example 20

From project empire-db, under directory /empire-db-examples/empire-db-example-cxf/src/main/java/org/apache/empire/samples/cxf/wssample/client/.

Source file: ClientGUI.java

  31 
vote

/** 
 * This method initializes _txtName
 * @return javax.swing.JTextField
 */
private JTextField get_txtName(){
  if (_txtName == null) {
    _txtName=new JTextField();
    _txtName.setLocation(new Point(120,225));
    _txtName.setPreferredSize(new Dimension(150,20));
    _txtName.setSize(new Dimension(150,20));
  }
  return _txtName;
}
 

Example 21

From project encog-java-workbench, under directory /src/main/java/org/encog/workbench/dialogs/common/.

Source file: InformationField.java

  31 
vote

public int createField(JPanel panel,int x,int y,int width){
  JTextArea l=new JTextArea(this.getLabel());
  l.setEditable(false);
  l.setLineWrap(true);
  l.setBackground(this.getOwner().getBackground());
  l.setWrapStyleWord(true);
  l.setSize(new Dimension(this.getOwner().getWidth(),this.height * (l.getFontMetrics(l.getFont())).getHeight()));
  this.setLabelControl(null);
  l.setLocation(new Point(0,y));
  panel.add(l);
  return y + 100;
}
 

Example 22

From project arquillian-rusheye, under directory /rusheye-impl/src/test/java/org/jboss/rusheye/result/writer/.

Source file: TestXmlResultWriter.java

  30 
vote

@org.testng.annotations.Test public void testXmlResultWriter() throws InterruptedException {
  Test test=new Test();
  Pattern pattern=new Pattern();
  ComparisonResult comparisonResult=new ComparisonResult();
  Rectangle rectangle=new Rectangle();
  Area area=new Area();
  test.setName("testName");
  test.getPatterns().add(pattern);
  pattern.setName("patternName");
  pattern.setComparisonResult(comparisonResult);
  pattern.setOutput("someLocation");
  pattern.setConclusion(ResultConclusion.PERCEPTUALLY_SAME);
  comparisonResult.setEqualPixels(3);
  comparisonResult.setDifferentPixels(4);
  comparisonResult.setPerceptibleDiffs(5);
  comparisonResult.setSmallDifferences(6);
  comparisonResult.setTotalPixels(7);
  comparisonResult.getRectangles().add(rectangle);
  comparisonResult.setArea(area);
  area.setWidth(8);
  area.setHeight(9);
  rectangle.setMin(new Point(10,11));
  rectangle.setMax(new Point(12,13));
  writer.write(test);
  writer.close();
  latch.await();
  Assert.assertNull(writer.validatingReader.validationMessage,writer.validatingReader.validationMessage);
}
 

Example 23

From project Briss, under directory /src/main/java/at/laborg/briss/gui/.

Source file: DrawableCropRect.java

  29 
vote

public void setNewHotCornerUL(Point p){
  int xLR=(int)getMaxX();
  int yLR=(int)getMaxY();
  setSize(xLR - p.x,yLR - p.y);
  x=p.x;
  y=p.y;
}
 

Example 24

From project cowgraph, under directory /CowGraph/CowGraphVisualEditor/src/zbeans/cowgraph/visual/editor/.

Source file: CowGraphVisualEditorScene.java

  29 
vote

CowGraphVisualEditorScene(){
  mainLayer=new LayerWidget(this);
  addChild(mainLayer);
  getActions().addAction(ActionFactory.createAcceptAction(new AcceptProvider(){
    @Override public ConnectorState isAcceptable(    Widget widget,    Point point,    Transferable transferable){
      Node node=NodeTransfer.node(transferable,NodeTransfer.DND_COPY_OR_MOVE);
      GraphElementType type=node.getLookup().lookup(GraphElementType.class);
      if (type != null) {
        return ConnectorState.ACCEPT;
      }
 else {
        return ConnectorState.REJECT;
      }
    }
    @Override public void accept(    Widget widget,    Point point,    Transferable transferable){
      addGraphElementsFromTransferable(transferable,widget.convertLocalToScene(point));
      getView().requestFocusInWindow();
    }
  }
));
  getActions().addAction(ActionFactory.createZoomAction());
  getActions().addAction(ActionFactory.createPanAction());
}
 

Example 25

From project dawn-isencia, under directory /com.isencia.passerelle.commons/src/main/java/com/isencia/util/swing/layout/.

Source file: AbsoluteConstraints.java

  29 
vote

/** 
 * Creates a new AbsoluteConstraints for specified position and size.
 * @param pos The position to be represented by this AbsoluteConstraints
 * @param size The size to be represented by this AbsoluteConstraints or nullif the component's preferred size should be used
 */
public AbsoluteConstraints(Point pos,Dimension size){
  this.x=pos.x;
  this.y=pos.y;
  if (size != null) {
    this.width=size.width;
    this.height=size.height;
  }
}
 

Example 26

From project drugis-common, under directory /common-gui/src/main/java/org/drugis/common/gui/table/.

Source file: EnhancedTableHeader.java

  29 
vote

private TableColumn getResizingColumn(Point p,int column){
  if (column == -1) {
    return null;
  }
  Rectangle r=getHeaderRect(column);
  r.grow(-3,0);
  if (r.contains(p)) {
    return null;
  }
  int midPoint=r.x + (r.width / 2);
  int columnIndex;
  if (getComponentOrientation().isLeftToRight()) {
    columnIndex=(p.x < midPoint) ? (column - 1) : column;
  }
 else {
    columnIndex=(p.x < midPoint) ? column : (column - 1);
  }
  if (columnIndex == -1) {
    return null;
  }
  return getColumnModel().getColumn(columnIndex);
}