Java Code Examples for java.awt.Point

The following are top voted examples for showing how to use java.awt.Point. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: incubator-netbeans   File: TableRendererTest.java   Source Code and License 7 votes vote down vote up
@Override
public boolean isCellEditable(EventObject anEvent) {
    if (anEvent.getSource() instanceof JTable) {
        JTable table = (JTable) anEvent.getSource();
        if (anEvent instanceof MouseEvent) {
            MouseEvent event = (MouseEvent) anEvent;
            Point p = event.getPoint();
            int row = table.rowAtPoint(p);
            int col = table.columnAtPoint(p);
            Rectangle rect = table.getCellRect(row, col, true);
            p.translate(-rect.x, -rect.y);
            System.out.println("isCellEditable("+anEvent+")");
            System.out.println("Point "+p+"in rectangle "+rect);
            if (p.x > rect.width - 24) {
                // last 24 points not editable
                return false;
            }
        }
    }
    return true;
}
 
Example 2
Project: SE2017-Team1   File: SingleRelationTests.java   Source Code and License 6 votes vote down vote up
@Test
  public void testCondFlip() throws Exception {
  	String fileNameExpected = "images/expected/cond_flip";
      ConditionFlipped graphExpected = new ConditionFlipped();
      TestUtil.drawAndSave(graphExpected, fileNameExpected);
      
      String fileNameGenerated = "images/generated/cond_flip";
      ConresGraph graph = new ConresGraph();
graph.activities = new ArrayList<ConresActivity>();
graph.relations = new ArrayList<ConresRelation>();
ConresActivity act1 = new ConresActivity(0, new Point(50, 35), "Activity 1", "ROLE", false, false, false);
ConresActivity act2 = new ConresActivity(1, new Point(250, 35), "Activity 2", "ROLE", false, false, false);
graph.activities.add(act1);
graph.activities.add(act2);
ConresRelation relation = new ConresRelation(act1, act2, "cond");
graph.relations.add(relation);
JPanel graphGenerated = crv.draw(graph);
      TestUtil.drawAndSave(graphGenerated, fileNameGenerated);
  	
  	String cs1 = TestUtil.getChecksum(fileNameExpected + IMAGE_FORMAT);
  	String cs2 = TestUtil.getChecksum(fileNameGenerated + IMAGE_FORMAT);
  	assertEquals(cs1, cs2);
  }
 
Example 3
Project: Neukoelln_SER316   File: EstimatePanel.java   Source Code and License 6 votes vote down vote up
private void newEstimateB_actionPerformed(ActionEvent e, String tasktext, Date startDate, Date endDate) {    	
  	EstimateDialog dlg = new EstimateDialog(App.getFrame(), Local.getString("New Estimate Worksheet"));
  	Dimension frmSize = App.getFrame().getSize();
  	Point loc = App.getFrame().getLocation();
  	dlg.setLocation((frmSize.width - dlg.getSize().width) / 2 + loc.x, (frmSize.height - dlg.getSize().height) / 2 + loc.y);    	
dlg.setVisible(true);

if (dlg.CANCELLED)
  		return;

// create Estimate			
  	int size = (int)dlg.loc.getValue();
  	int time = (int)dlg.minutes.getValue();
  	//PSP.Phase phase = PSP.Phase.valueOf(PSP.reverseConversion(dlg.phase.getSelectedItem().toString(),0));
  	PSP.Phase phase = PSP.Phase.valueOf(dlg.phase.getSelectedItem().toString());
  	String comments = dlg.comments.getText();		
  	String mod = dlg.module.getText();			
  	EstimateManager.createEstimate(phase, mod, size, time, comments);
  	saveEstimate();
  }
 
Example 4
Project: brModelo   File: EapBarraLigacao.java   Source Code and License 6 votes vote down vote up
/**
 * Qual a forma mais a direita e qual a mais a esquerda e qual a distnacia delas ao 'centro' da EAP
 *
 * @param areas
 * @return p.x = LEFT e p.y = Right
 */
protected Point calcDifCentroEapHorizontal(HashMap<Forma, EapBarraLigacao> areas) {
    ArrayList<Forma> lst = getListaDeFormasLigadas();
    Forma ma = capturePrincipal();
    lst.remove(ma);
    Forma fmE = getFormaMaisEsquerda(lst);
    Forma fmD = getFormaMaisDireita(lst);
    ArrayList<EapBarraLigacao> jatmp = new ArrayList<>();

    fmE = (areas.get(fmE) == null ? fmE : areas.get(fmE).calcMaisAEsquerda(jatmp, areas));
    jatmp = new ArrayList<>();
    fmD = (areas.get(fmD) == null ? fmD : areas.get(fmD).calcMaisADireita(jatmp, areas));

    int tamE = ma.getLeft() + (ma.getWidth() / 2) - fmE.getLeft();
    int tamD = fmD.getLeftWidth() - (ma.getLeftWidth() - (ma.getWidth() / 2));

    return new Point(tamE, tamD);
}
 
Example 5
Project: AeroStory   File: MapleMap.java   Source Code and License 6 votes vote down vote up
public final void spawnItemDrop(final MapleMapObject dropper, final MapleCharacter owner, final Item item, Point pos, final boolean ffaDrop, final boolean playerDrop) {
    final Point droppos = calcDropPos(pos, pos);
    final MapleMapItem drop = new MapleMapItem(item, droppos, dropper, owner, (byte) (ffaDrop ? 2 : 0), playerDrop);

    spawnAndAddRangedMapObject(drop, new DelayedPacketCreation() {
        @Override
        public void sendPackets(MapleClient c) {
            c.announce(MaplePacketCreator.dropItemFromMapObject(drop, dropper.getPosition(), droppos, (byte) 1));
        }
    }, null);
    broadcastMessage(MaplePacketCreator.dropItemFromMapObject(drop, dropper.getPosition(), droppos, (byte) 0));

    if (!everlast) {
        TimerManager.getInstance().schedule(new ExpireMapItemJob(drop), 180000);
        activateItemReactors(drop, owner.getClient());
    }
}
 
Example 6
Project: JavaGraph   File: ContributorsTable.java   Source Code and License 6 votes vote down vote up
@Override
public void mouseClicked(MouseEvent e) {
    JTable table = (JTable) e.getSource();
    Point pt = e.getPoint();
    int ccol = table.columnAtPoint(pt);
    int crow = table.rowAtPoint(pt);
    Object value = table.getValueAt(crow, ccol);
    if (value instanceof URL) {
        URL url = (URL) value;
        try {
            if (Desktop.isDesktopSupported()) {
                Desktop.getDesktop().browse(url.toURI());
            }
        } catch (Exception ex) {
            throw new IllegalStateException(ex);
        }
    }
}
 
Example 7
Project: Lucid2.0   File: CField.java   Source Code and License 6 votes vote down vote up
public static byte[] getCapturePosition(MapleMap map) {
    PacketWriter pw = new PacketWriter();

    Point p1 = map.getPointOfItem(2910000);
    Point p2 = map.getPointOfItem(2910001);
    pw.writeShort(SendPacketOpcode.CAPTURE_POSITION.getValue());
    pw.write(p1 == null ? 0 : 1);
    if (p1 != null) {
        pw.writeInt(p1.x);
        pw.writeInt(p1.y);
    }
    pw.write(p2 == null ? 0 : 1);
    if (p2 != null) {
        pw.writeInt(p2.x);
        pw.writeInt(p2.y);
    }

    return pw.getPacket();
}
 
Example 8
Project: jmt   File: DefaultIconsToolkit.java   Source Code and License 6 votes vote down vote up
@Override
public Image getEdgeIcon(Rectangle bounds, Point[] anglePoints) {
	/*creates background image.*/
	BufferedImage bgImage = new BufferedImage(bounds.width, bounds.height, BufferedImage.TYPE_4BYTE_ABGR);
	Graphics bgGr = bgImage.getGraphics();
	bgGr.setColor(new Color(0, 0, 0, 0));
	bgGr.fillRect(0, 0, bounds.width, bounds.height);
	for (int i = 0; i < anglePoints.length - 1; i++) {
		//Must convert absolute coords to local coords
		int x0 = anglePoints[i].x - bounds.x, y0 = anglePoints[i].y - bounds.y, x1 = anglePoints[i + 1].x - bounds.x, y1 = anglePoints[i + 1].y
				- bounds.y;
		bgGr.setColor(Color.GRAY);
		bgGr.drawLine(x0, y0, x1, y1);
		bgGr.setColor(new Color(30, 30, 30, 30));
		//bgGr.fillRect(Math.min(x0,x1)-1, Math.min(y0,y1)-1, Math.abs(x1-x0)+3, Math.abs(y1-y0)+3);
		bgGr.drawLine(x0 - 1, y0 - 1, x1 - 1, y1 - 1);
	}
	return bgImage;
}
 
Example 9
Project: incubator-netbeans   File: GlassPane.java   Source Code and License 6 votes vote down vote up
/**
 * Calculates the grid location of the moved component.
 *
 * @param cursorLocation current position of the cursor.
 */
void calculateMovingGridLocation(Point cursorLocation) {
    Point start = toComponentPane(draggingStart);
    Point end = toComponentPane(cursorLocation);
    int startX = gridXLocation(start.x, true);
    int startY = gridYLocation(start.y, true);
    int endX = gridXLocation(end.x, false);
    int endY = gridYLocation(end.y, false);
    int deltaX = endX-startX;
    int deltaY = endY-startY;
    deltaX = Math.max(deltaX, -selMinX);
    deltaY = Math.max(deltaY, -selMinY);
    int tempGridX = gridInfo.getGridX(focusedComponent) + deltaX;
    int tempGridY = gridInfo.getGridY(focusedComponent) + deltaY;
    if( !gridInfo.isGapColumn(tempGridX) && !gridInfo.isGapRow(tempGridY) ) {
        newGridX = tempGridX;
        newGridY = tempGridY;
    }
}
 
Example 10
Project: Pogamut3   File: DnDMoveProvider.java   Source Code and License 6 votes vote down vote up
@Override
public void setNewLocation(Widget w, Point currentLocation) {
    ghost.setPreferredLocation(currentLocation);

    Point center = getGhostCenter();
    PoshWidget<? extends PoshElement> hitWidget = this.findContainingWidget(center);
    if (hitWidget == null) {
        ghost.setBorder(FUTILE_BORDER);
        return;
    }

    List<AbstractAcceptAction> acceptProviders = hitWidget.getAcceptProviders();

    for (AbstractAcceptAction acceptProvider : acceptProviders) {
        DataFlavor ghostDataFlavor = ghost.associatedWidget.getDataNode().getDataFlavor();
        DataFlavor acceptDataFlavor = acceptProvider.getDataFlavor();

        if (acceptDataFlavor.equals(ghostDataFlavor)) {
            ghost.setBorder(ACCEPTING_BORDER);
            return;
        }
    }
    ghost.setBorder(FUTILE_BORDER);
}
 
Example 11
Project: jdk8u-jdk   File: PolicyTool.java   Source Code and License 6 votes vote down vote up
/**
 * displays a dialog box describing an error which occurred.
 */
void displayErrorDialog(Window w, String error) {
    ToolDialog ed = new ToolDialog
            (PolicyTool.getMessage("Error"), tool, this, true);

    // find where the PolicyTool gui is
    Point location = ((w == null) ?
            getLocationOnScreen() : w.getLocationOnScreen());
    //ed.setBounds(location.x + 50, location.y + 50, 600, 100);
    ed.setLayout(new GridBagLayout());

    JLabel label = new JLabel(error);
    addNewComponent(ed, label, 0,
                    0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.BOTH);

    JButton okButton = new JButton(PolicyTool.getMessage("OK"));
    ActionListener okListener = new ErrorOKButtonListener(ed);
    okButton.addActionListener(okListener);
    addNewComponent(ed, okButton, 1,
                    0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.VERTICAL);

    ed.getRootPane().setDefaultButton(okButton);
    ed.getRootPane().registerKeyboardAction(okListener, escKey, JComponent.WHEN_IN_FOCUSED_WINDOW);

    ed.pack();
    ed.setLocationRelativeTo(w);
    ed.setVisible(true);
}
 
Example 12
Project: TrabalhoFinalEDA2   File: mxGraphOutline.java   Source Code and License 6 votes vote down vote up
/**
 * Paints the graph outline.
 */
public void paintGraph(Graphics g)
{
	if (graphComponent != null)
	{
		Graphics2D g2 = (Graphics2D) g;
		AffineTransform tx = g2.getTransform();

		try
		{
			Point tr = graphComponent.getGraphControl().getTranslate();
			g2.translate(translate.x + tr.getX() * scale,
					translate.y + tr.getY() * scale);
			g2.scale(scale, scale);

			// Draws the scaled graph
			graphComponent.getGraphControl().drawGraph(g2, drawLabels);
		}
		finally
		{
			g2.setTransform(tx);
		}
	}
}
 
Example 13
Project: genetic-algorithm   File: VorführungGenAdv.java   Source Code and License 6 votes vote down vote up
static void loop(Simulation sim, PrintWriter out) throws GameOver {
	SimulationState simState = sim.getSimulationState();
	bot.update(simState);

	if (bot.bomb) {
		System.out.println("true");
		out.println("true");
		sim.update(true);
	} else {
		int x = bot.x;
		int y = bot.y;

		System.out.println(x + " " + y);
		out.println(x + " " + y);
		sim.update(new Point(x, y));
	}

}
 
Example 14
Project: alevin-svn2   File: MySatelliteVisualizationViewer.java   Source Code and License 6 votes vote down vote up
@Override
public void paint(Graphics g) {
	ShapeTransformer masterViewTransformer = master.getRenderContext()
			.getMultiLayerTransformer().getTransformer(Layer.VIEW);
	ShapeTransformer masterLayoutTransformer = master
			.getRenderContext().getMultiLayerTransformer()
			.getTransformer(Layer.LAYOUT);
	ShapeTransformer vvLayoutTransformer = vv.getRenderContext()
			.getMultiLayerTransformer().getTransformer(Layer.LAYOUT);

	// changed: bounds without offset
	Shape lens = new Rectangle(new Point(), master.getSize());

	lens = masterViewTransformer.inverseTransform(lens);
	lens = masterLayoutTransformer.inverseTransform(lens);
	lens = vvLayoutTransformer.transform(lens);
	Graphics2D g2d = (Graphics2D) g;
	Color old = g.getColor();
	Color lensColor = master.getBackground();
	vv.setBackground(lensColor.darker());
	g.setColor(lensColor);
	g2d.fill(lens);
	g.setColor(Color.gray);
	g2d.draw(lens);
	g.setColor(old);
}
 
Example 15
Project: VTerminal   File: ImagePrinter.java   Source Code and License 6 votes vote down vote up
/**
 * Prints an image on a component.
 *
 * @param component
 *         The component.
 *
 * @param columnIndex
 *         The x-axis (column) coordinate of the top-left character.
 *
 * @param rowIndex
 *         The y-axis (row) coordinate of the top-left character.
 *
 * @throws NullPointerException
 *         If the screen is null.
 */
private void print(final @NonNull Component component, final int columnIndex, final int rowIndex) {
    final BufferedImage temp = applyTransformations();
    final Point charPosition = new Point(0, 0);

    for (int y = 0 ; y < temp.getHeight() && y < component.getHeight() ; y++) {
        for (int x = 0 ; x < temp.getWidth() && x < component.getWidth() ; x++) {
            final int hexColor = temp.getRGB(x,y);
            final int red = (hexColor & 0x00ff0000) >> 16;
            final int green = (hexColor & 0x0000ff00) >> 8;
            final int blue =  hexColor & 0x000000ff;

            final int charX = x + columnIndex;
            final int charY = y + rowIndex;
            charPosition.setLocation(charX, charY);

            final AsciiCharacter character = component.getCharacterAt(charPosition);
            character.setCharacter(printChar);
            character.setForegroundColor(new Color(red, green, blue));
        }
    }
}
 
Example 16
Project: litiengine   File: Spritesheet.java   Source Code and License 6 votes vote down vote up
public BufferedImage getSprite(final int index) {
  final String imageCacheKey = MessageFormat.format("{0}_{1}", this.hashCode, index);
  if (ImageCache.SPRITES.containsKey(imageCacheKey)) {
    return ImageCache.SPRITES.get(imageCacheKey);
  }

  if (this.getImage() == null) {
    log.warning("no image defined for sprite '" + this.getName() + "'");
    return null;
  }

  final Point position = this.getLocation(index);
  try {
    final BufferedImage smallImage = this.getImage().getSubimage(position.x, position.y, this.spriteWidth, this.spriteHeight);
    ImageCache.SPRITES.put(imageCacheKey, smallImage);
    return smallImage;
  } catch (final RasterFormatException rfe) {
    log.warning("could not read sprite of size [" + this.spriteWidth + "x" + this.spriteHeight + " at position [" + position.x + "," + position.y + "] from sprite'" + this.getName() + "'");
    return null;
  }
}
 
Example 17
Project: incubator-netbeans   File: ShortcutCellPanel.java   Source Code and License 6 votes vote down vote up
private void changeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_changeButtonActionPerformed
    JComponent tf = changeButton;
    Point p = new Point(tf.getX(), tf.getY());
    SwingUtilities.convertPointToScreen(p, this);
    //show special key popup
    if (popup == null) {
        changeButton.setText(""); // NOI18N
        changeButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/netbeans/modules/options/keymap/more_closed.png")));
        if (Utilities.isUnix()) {
            // #156869 workaround, force HW for Linux
            popup = PopupFactory.getSharedInstance().getPopup(null, specialkeyList, p.x, p.y + tf.getHeight());
        } else {
            popup = factory.getPopup(this, specialkeyList, p.x, p.y + tf.getHeight());
        }
        popup.show();
    } else {
        changeButton.setText(""); // NOI18N
        changeButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/netbeans/modules/options/keymap/more_opened.png")));
        hidePopup();
    }
}
 
Example 18
Project: incubator-netbeans   File: CloseButtonHandler.java   Source Code and License 6 votes vote down vote up
@Override
public void mouseMoved( MouseEvent e ) {
    if( e.getSource() instanceof TabTable ) {
        int closeButtonRow = -1;
        int closeButtonColumn = -1;
        TabTable table = ( TabTable ) e.getSource();
        Point p = e.getPoint();
        int row = table.rowAtPoint( p );
        int col = table.columnAtPoint( p );
        if( row >= 0 && col >= 0 ) {
            TableCellRenderer ren = table.getCellRenderer( row, col );
            if( ren instanceof TabDataRenderer ) {
                TabDataRenderer tabRenderer = ( TabDataRenderer ) ren;
                if( tabRenderer.isInCloseButton( table.getCellRect( row, col, true ), p ) ) {
                    closeButtonRow = row;
                    closeButtonColumn = col;
                }
            }
        }
        table.setCurrentCloseButtonCoords( closeButtonRow, closeButtonColumn );
    }
}
 
Example 19
Project: Pixie   File: ResizeTest.java   Source Code and License 6 votes vote down vote up
@Test
public void testOriginalToResized_03() {
    final String testDescription = "----------originalToResized_03----------\n"
            + " Summary: Test of originalToResized(int, int) method, of class Resize\n"
            + " Description: Check if the resize ratio of 1.0 is outputing the same input value. Check if resize ratio 1.0 is neutral element / identity element. Input point (10, 10), the resize is set to (1.0, 1.0).\n"
            + " Pre-conditions: none\n"
            + " Conditions: none\n"
            + " Expected result: It shall output the point (10, 10); no errors or exceptions shall occur.\n";
    System.out.println(testDescription);

    int x = 10;
    int y = 10;
    Resize instance = new Resize(1.0, 1.0);
    Point expResult = new Point(10, 10);
    Point result = instance.originalToResized(x, y);
    assertEquals(expResult, result);
}
 
Example 20
Project: jmt   File: Convex3DGraph.java   Source Code and License 6 votes vote down vote up
public void mouseReleased(MouseEvent evt) {
	switch (evt.getButton()) {
	case MouseEvent.BUTTON1: {
		mouseLeft = false;
		break;
	}
	case MouseEvent.BUTTON2: {
		mouseRight = false;
		break;
	}
	}
	if (!mouseLeft && !mouseRight) {
		mouseMode = MouseMode.NONE;
	}
	// This is the last mouse action, so keep track of it.
	mouseEnd.x = evt.getX();
	mouseEnd.y = evt.getY();
	mouseDelta = new Point(mouseEnd.x - mouseStart.x, mouseEnd.y
			- mouseStart.y);
	repaint();
}
 
Example 21
Project: jdk8u-jdk   File: MutterMaximizeTest.java   Source Code and License 6 votes vote down vote up
private static Thread startRegTest(final Frame f) {
    Thread robot = new Thread(new Runnable() {
        public void run() {
            Robot r = Util.createRobot();
            dragWindow(f, 100, 100, r);
            // wait for the location to be set.
            sleepFor(2000);

            final Point l2 = f.getLocationOnScreen();

            // double click should maximize the frame
            doubleClick(r);

            // wait for location again.
            sleepFor(2000);
            final Point l3 = f.getLocationOnScreen();
            if (l3.equals(l2)) {
                throw new RuntimeException("Bad location after maximize. Window location has not moved");
            }
        }
    });
    return robot;
}
 
Example 22
Project: JDigitalSimulator   File: ALU74181.java   Source Code and License 5 votes vote down vote up
protected void setContactLocations() {
	inputs[0].setLocation(new Point(0, 52)); //M
	inputs[1].setLocation(new Point(0, 60)); //Cn
	outputs[0].setLocation(new Point(size.width, 17)); //P
	outputs[1].setLocation(new Point(size.width, 25)); //G
	outputs[2].setLocation(new Point(size.width, 43)); //Cn+4
	outputs[3].setLocation(new Point(size.width, 61)); //A=B
	for(int number=0;number<4;number++) {
		int top = 63+number*20;
		inputsA[number].setLocation(new Point(0, top+18)); //A
		inputsB[number].setLocation(new Point(0, top+28)); //B
		inputsS[number].setLocation(new Point(0, 9+number*10)); //S
		outputsF[number].setLocation(new Point(size.width, top+22)); //F
	}
}
 
Example 23
Project: Neukoelln_SER316   File: HTMLEditor.java   Source Code and License 5 votes vote down vote up
void setElementProperties(Element el, String id, String cls, String sty) {
	ElementDialog dlg = new ElementDialog(null);
	//dlg.setLocation(linkActionB.getLocationOnScreen());
	Dimension dlgSize = dlg.getPreferredSize();
	Dimension frmSize = this.getSize();
	Point loc = this.getLocationOnScreen();
	dlg.setLocation(
		(frmSize.width - dlgSize.width) / 2 + loc.x,
		(frmSize.height - dlgSize.height) / 2 + loc.y);
	dlg.setModal(true);
	dlg.setTitle(Local.getString("Object properties"));
	dlg.idField.setText(id);
	dlg.classField.setText(cls);
	dlg.styleField.setText(sty);
	// Uncommented, returns a simple p into the header... fix needed ?
	//dlg.header.setText(el.getName());
	dlg.setVisible(true);
	if (dlg.CANCELLED)
		return;
	SimpleAttributeSet attrs = new SimpleAttributeSet(el.getAttributes());
	if (dlg.idField.getText().length() > 0)
		attrs.addAttribute(HTML.Attribute.ID, dlg.idField.getText());
	if (dlg.classField.getText().length() > 0)
		attrs.addAttribute(HTML.Attribute.CLASS, dlg.classField.getText());
	if (dlg.styleField.getText().length() > 0)
		attrs.addAttribute(HTML.Attribute.STYLE, dlg.styleField.getText());
	document.setParagraphAttributes(el.getStartOffset(), 0, attrs, true);
}
 
Example 24
Project: MaxSim   File: InputSlotWidget.java   Source Code and License 5 votes vote down vote up
public InputSlotWidget(InputSlot slot, DiagramScene scene, Widget parent, FigureWidget fw) {
    super(slot, scene, parent, fw);
    inputSlot = slot;
    //init();
    //getFigureWidget().getLeftWidget().addChild(this);
    Point p = inputSlot.getRelativePosition();
    p.x -= this.calculateClientArea().width / 2;
    p.y += Figure.SLOT_START;
    this.setPreferredLocation(p);
}
 
Example 25
Project: brModelo   File: SuperLinha.java   Source Code and License 5 votes vote down vote up
@Override
protected void ProcessaDblClick(MouseEvent e) {
    Point p = e.getPoint();
    for (int i = 1; i < getPontosParaDesenho().length; i++) {
        if (Linha.SegmentIntersectRectangle(p.x - 1, p.y - 1, p.x + 1, p.y + 1,
                getPontosParaDesenho()[i - 1].x, getPontosParaDesenho()[i - 1].y,
                getPontosParaDesenho()[i].x, getPontosParaDesenho()[i].y)) {
            PontoDeLinha pt = InserirPonto(i);
            pt.setCentro(p);
            //pt.IsHide = false;
            pt.setVisible(true);
            mouseExited(null);//evita que a linha permaneça na forma do mouseEntred.
            return;
        }
    }
}
 
Example 26
Project: MaxSim   File: PolylineRouter.java   Source Code and License 5 votes vote down vote up
private boolean intersects(Collection<Widget> nodeWidgets, Point start, Point end) {
    List<Point> pointlist = new ArrayList<>();
    pointlist.add(start);
    pointlist.add(end);

    for(Widget w : nodeWidgets){
        if(w.isVisible() && intersects(w, pointlist)) {
            return true;
        }
    }
    return false;
}
 
Example 27
Project: OpenJSharp   File: SunDragSourceContextPeer.java   Source Code and License 5 votes vote down vote up
/**
 * initiate a DnD operation ...
 */

public void startDrag(DragSourceContext dsc, Cursor c, Image di, Point p)
  throws InvalidDnDOperationException {

    /* Fix for 4354044: don't initiate a drag if event sequence provided by
     * DragGestureRecognizer is empty */
    if (getTrigger().getTriggerEvent() == null) {
        throw new InvalidDnDOperationException("DragGestureEvent has a null trigger");
    }

    dragSourceContext = dsc;
    cursor            = c;
    sourceActions     = getDragSourceContext().getSourceActions();
    dragImage         = di;
    dragImageOffset   = p;

    Transferable transferable  = getDragSourceContext().getTransferable();
    SortedMap<Long,DataFlavor> formatMap = DataTransferer.getInstance().
        getFormatsForTransferable(transferable, DataTransferer.adaptFlavorMap
            (getTrigger().getDragSource().getFlavorMap()));
    long[] formats = DataTransferer.getInstance().
        keysToLongArray(formatMap);
    startDrag(transferable, formats, formatMap);

    /*
     * Fix for 4613903.
     * Filter out all mouse events that are currently on the event queue.
     */
    discardingMouseEvents = true;
    EventQueue.invokeLater(new Runnable() {
            public void run() {
                discardingMouseEvents = false;
            }
        });
}
 
Example 28
Project: VASSAL-src   File: FreeRotator.java   Source Code and License 5 votes vote down vote up
private Point getGhostPosition() {
  final AffineTransform t =
    AffineTransform.getRotateInstance(-PI_180 * (tempAngle - getAngle()),
                                      pivot.x + centerX(),
                                      pivot.y + centerY());
  final Point2D newPos2D =
    new Point2D.Float(getPosition().x, getPosition().y);
  t.transform(newPos2D, newPos2D);
  return new Point((int) Math.round(newPos2D.getX()),
                   (int) Math.round(newPos2D.getY()));
}
 
Example 29
Project: incubator-netbeans   File: FileCompletionPopup.java   Source Code and License 5 votes vote down vote up
public void mouseDragged(MouseEvent e) {
    if (e.getSource() == list) {
        return;
    }
    if ( isVisible() ) {
        MouseEvent newEvent = convertMouseEvent( e );
        Rectangle r = new Rectangle();
        list.computeVisibleRect( r );
        Point location =  newEvent.getPoint();
        int index = list.locationToIndex(location);
        if ( r.contains( location ) ) {
            list.setSelectedIndex(index);
        }
    }
}
 
Example 30
Project: incubator-netbeans   File: CheckListener.java   Source Code and License 5 votes vote down vote up
public void mouseClicked(MouseEvent e) {
    // todo (#pf): we need to solve problem between click and double
    // click - click should be possible only on the check box area
    // and double click should be bordered by title text.
    // we need a test how to detect where the mouse pointer is
    JTree tree = (JTree) e.getSource();
    Point p = e.getPoint();
    int x = e.getX();
    int y = e.getY();
    int row = tree.getRowForLocation(x, y);
    TreePath path = tree.getPathForRow(row);

    // if path exists and mouse is clicked exactly once
    if( null == path )
        return;
    
    Node node = Visualizer.findNode( path.getLastPathComponent() );
    if( null == node )
        return;
    
    Rectangle chRect = CheckRenderer.getCheckBoxRectangle();
    Rectangle rowRect = tree.getPathBounds(path);
    chRect.setLocation(chRect.x + rowRect.x, chRect.y + rowRect.y);
    if (e.getClickCount() == 1 && chRect.contains(p)) {
        boolean isSelected = settings.isNodeVisible( node );
        settings.setNodeVisible( node, !isSelected );
        tree.repaint();
    }
}
 
Example 31
Project: Tarski   File: JTableRenderer.java   Source Code and License 5 votes vote down vote up
public void dragOver(DropTargetDragEvent e)
{
	if (!((mxGraphTransferHandler) graphContainer.getTransferHandler())
			.isLocalDrag()
			&& JTableRenderer.this != dragSource)
	{
		Point p = e.getLocation();
		int row = rowAtPoint(p);
		getSelectionModel().setSelectionInterval(row, row);
	}
}
 
Example 32
Project: MaxSim   File: CfgScene.java   Source Code and License 5 votes vote down vote up
private void centerSelection() {
    Point sceneCenter = null;
    Collection<CfgNode> nodes = this.selectedNodes;
    if (nodes.size() == 0) {
        nodes = this.getNodes();
    }

    for (CfgNode n : nodes) {
        if (sceneCenter == null) {
            sceneCenter = this.findWidget(n).getLocation();
            continue;
        }
        Point location = this.findWidget(n).getLocation();
        sceneCenter.x = (location.x + sceneCenter.x) / 2;
        sceneCenter.y = (location.y + sceneCenter.y) / 2;
    }

    JComponent view = this.getView();
    if (view != null) {
        Rectangle viewBounds = view.getVisibleRect();

        Point viewCenter = this.convertSceneToView(sceneCenter);

        view.scrollRectToVisible(new Rectangle(
                viewCenter.x - viewBounds.width / 2,
                viewCenter.y - viewBounds.height / 2,
                viewBounds.width,
                viewBounds.height));
    }
}
 
Example 33
Project: incubator-netbeans   File: PropertyPanelInDialogTest.java   Source Code and License 5 votes vote down vote up
private void clickOn(final PropertyPanel ren) throws Exception {
    SwingUtilities.invokeAndWait(new Runnable() {
        public void run() {
            Point toClick = new Point(5,5);
            Component target=ren.getComponentAt(toClick);
            MouseEvent me = new MouseEvent(target, MouseEvent.MOUSE_PRESSED, System.currentTimeMillis(), MouseEvent.BUTTON1_MASK, toClick.x, toClick.y, 2, false);
            target.dispatchEvent(me);
        }
    });
    sleep();
}
 
Example 34
Project: VASSAL-src   File: Map.java   Source Code and License 5 votes vote down vote up
/**
 * Return the name of the deck whose position is p
 *
 * @param p
 * @return
 */
public String getDeckNameAt(Point p) {
  String deck = null;
  if (p != null) {
    for (DrawPile d : getComponentsOf(DrawPile.class)) {
      if (d.getPosition().equals(p)) {
        deck = d.getConfigureName();
        break;
      }
    }
  }
  return deck;
}
 
Example 35
Project: rapidminer   File: ListPropertyTable.java   Source Code and License 5 votes vote down vote up
/** This method ensures that the correct tool tip for the current table cell is delivered. */
@Override
public String getToolTipText(MouseEvent e) {
	Point p = e.getPoint();
	int column = columnAtPoint(p);
	if (column == 0) {
		return keyToolTip;
	} else {
		return super.getToolTipText(e);
	}
}
 
Example 36
Project: VASSAL-src   File: MapBoard.java   Source Code and License 5 votes vote down vote up
/**
 * Move the upper left and lower-right points to just within the map board.
 */
void constrainRectangle(Point upperLeft, Point lowerRight) {
  if (upperLeft.x < 0)
    upperLeft.x = 0;
  if (upperLeft.y < 0)
    upperLeft.y = 0;
  Dimension d = getBoardSize();

  if (lowerRight.x >= d.width)
    lowerRight.x = d.width-1;
  if (lowerRight.y >= d.height)
    lowerRight.y = d.height-1;
}
 
Example 37
Project: openjdk-jdk10   File: IntegerInterleavedRaster.java   Source Code and License 5 votes vote down vote up
/**
 * Creates a subraster given a region of the raster.  The x and y
 * coordinates specify the horizontal and vertical offsets
 * from the upper-left corner of this raster to the upper-left corner
 * of the subraster.  A subset of the bands of the parent Raster may
 * be specified.  If this is null, then all the bands are present in the
 * subRaster. A translation to the subRaster may also be specified.
 * Note that the subraster will reference the same
 * DataBuffer as the parent raster, but using different offsets.
 * @param x               X offset.
 * @param y               Y offset.
 * @param width           Width (in pixels) of the subraster.
 * @param height          Height (in pixels) of the subraster.
 * @param x0              Translated X origin of the subraster.
 * @param y0              Translated Y origin of the subraster.
 * @param bandList        Array of band indices.
 * @exception RasterFormatException
 *            if the specified bounding box is outside of the parent raster.
 */
public WritableRaster createWritableChild (int x, int y,
                                           int width, int height,
                                           int x0, int y0,
                                           int bandList[]) {
    if (x < this.minX) {
        throw new RasterFormatException("x lies outside raster");
    }
    if (y < this.minY) {
        throw new RasterFormatException("y lies outside raster");
    }
    if ((x+width < x) || (x+width > this.minX + this.width)) {
        throw new RasterFormatException("(x + width) is outside raster");
    }
    if ((y+height < y) || (y+height > this.minY + this.height)) {
        throw new RasterFormatException("(y + height) is outside raster");
    }

    SampleModel sm;

    if (bandList != null)
        sm = sampleModel.createSubsetSampleModel(bandList);
    else
        sm = sampleModel;

    int deltaX = x0 - x;
    int deltaY = y0 - y;

    return new IntegerInterleavedRaster(sm,
                                      (DataBufferInt) dataBuffer,
                                      new Rectangle(x0,y0,width,height),
                                      new Point(sampleModelTranslateX+deltaX,
                                                sampleModelTranslateY+deltaY),
                                      this);
}
 
Example 38
Project: incubator-netbeans   File: DefaultTabbedContainerUI.java   Source Code and License 5 votes vote down vote up
public Polygon getInsertTabIndication(int idx) {
    Polygon result = tabDisplayer.getUI().getInsertTabIndication(idx);
    scratchPoint.setLocation(0,0);
    Point p = SwingUtilities.convertPoint(tabDisplayer, scratchPoint, container);
    result.translate (-p.x, -p.y);
    return appendContentBoundsTo(result);
}
 
Example 39
Project: openjdk-jdk10   File: JTableOperator.java   Source Code and License 5 votes vote down vote up
/**
 * Maps {@code JTable.rowAtPoint(Point)} through queue
 */
public int rowAtPoint(final Point point) {
    return (runMapping(new MapIntegerAction("rowAtPoint") {
        @Override
        public int map() {
            return ((JTable) getSource()).rowAtPoint(point);
        }
    }));
}
 
Example 40
Project: poe-ladder-tracker-java   File: GUILadderTracker.java   Source Code and License 5 votes vote down vote up
public void mouseDragged(MouseEvent e){
	if(rightMouseButtonPressed){
  Point currCoords = e.getLocationOnScreen();
  windowLadderTracker.setLocation(currCoords.x - mouseDownCompCoords.x, currCoords.y - mouseDownCompCoords.y);
  prefs.put("LadderTrackerLocationX", Integer.toString(currCoords.x - mouseDownCompCoords.x));
  prefs.put("LadderTrackerLocationY", Integer.toString(currCoords.y - mouseDownCompCoords.y));
	}
}
 
Example 41
Project: Progetto-B   File: CardListener.java   Source Code and License 5 votes vote down vote up
/**
 * When the cursor exits a card, the card is moved back to its original
 * depth.
 *
 * @param e
 */
@Override
public void mouseExited(MouseEvent e) {
    if (game.getPhase().equals(PLAY_CARDS)) {
        JLabel label = (JLabel) e.getComponent();
        cardPanel.getCardsPane().setLayer(label, cardPanel.getLabelLayer(label));
        String card = (String) label.getClientProperty("name");
        label.setIcon(new ImageIcon("src/resources/images/" + card + ".png"));
        Point p = label.getLocation();
        Point p1 = new Point(p.x, LOW_Y);
        label.setLocation(p1);
        cardPanel.updateUI();
    }
}
 
Example 42
Project: incubator-netbeans   File: SummaryCellRenderer.java   Source Code and License 5 votes vote down vote up
@Override
public boolean mouseClicked (Point p) {
    for (Map.Entry<Component, Rectangle> e : bounds.entrySet()) {
        if (e.getValue().contains(p)) {
            summaryView.moreRevisions(moreLabelValues.get(e.getKey()));
            return true;
        }
    }
    return false;
}
 
Example 43
Project: Lucid2.0   File: MapleMap.java   Source Code and License 5 votes vote down vote up
public final List<MaplePortal> getPortalsInRange(final Point from, final double rangeSq) {
    final List<MaplePortal> ret = new ArrayList<>();
    for (MaplePortal type : portals.values()) {
        if (from.distanceSq(type.getPosition()) <= rangeSq && type.getTargetMapId() != mapid && type.getTargetMapId() != 999999999) {
            ret.add(type);
        }
    }
    return ret;
}
 
Example 44
Project: openjdk-jdk10   File: Raster.java   Source Code and License 5 votes vote down vote up
/**
 * Create a compatible WritableRaster with the specified size, a new
 * SampleModel, and a new initialized DataBuffer.
 * @param w the specified width of the new {@code WritableRaster}
 * @param h the specified height of the new {@code WritableRaster}
 * @return a compatible {@code WritableRaster} with the specified
 *         size and a new sample model and data buffer.
 * @exception RasterFormatException if the width or height is less than
 *                               or equal to zero.
 */
public WritableRaster createCompatibleWritableRaster(int w, int h) {
    if (w <= 0 || h <=0) {
        throw new RasterFormatException("negative " +
                                      ((w <= 0) ? "width" : "height"));
    }

    SampleModel sm = sampleModel.createCompatibleSampleModel(w,h);

    return new SunWritableRaster(sm, new Point(0,0));
}
 
Example 45
Project: openjdk-jdk10   File: ChoiceDriver.java   Source Code and License 5 votes vote down vote up
@Override
public void selectItem(ComponentOperator oper, int index) {
    ChoiceOperator coper = (ChoiceOperator) oper;
    Point pointToClick = getClickPoint(oper);
    DriverManager.getMouseDriver(oper).
            clickMouse(oper, pointToClick.x, pointToClick.y,
                    1, Operator.getDefaultMouseButton(), 0,
                    oper.getTimeouts().create("ComponentOperator.MouseClickTimeout"));
    KeyDriver kdriver = DriverManager.getKeyDriver(oper);
    Timeout pushTimeout = oper.getTimeouts().create("ComponentOperator.PushKeyTimeout");
    if (System.getProperty("java.specification.version").compareTo("1.3") > 0) {
        while (coper.getSelectedIndex() != index) {
            kdriver.pushKey(oper, (index > coper.getSelectedIndex()) ? KeyEvent.VK_DOWN : KeyEvent.VK_UP, 0, pushTimeout);
        }
    } else {
        int current = ((ChoiceOperator) oper).getSelectedIndex();
        int diff = 0;
        int key = 0;
        if (index > current) {
            diff = index - current;
            key = KeyEvent.VK_DOWN;
        } else {
            diff = current - index;
            key = KeyEvent.VK_UP;
        }
        for (int i = 0; i < diff; i++) {
            kdriver.pushKey(oper, key, 0, pushTimeout);
        }
    }
    kdriver.pushKey(oper, KeyEvent.VK_ENTER, 0, pushTimeout);
}
 
Example 46
Project: openjdk-jdk10   File: AquaComboBoxPopup.java   Source Code and License 5 votes vote down vote up
@Override
public void show() {
    final int startItemCount = comboBox.getItemCount();

    final Rectangle popupBounds = adjustPopupAndGetBounds();
    if (popupBounds == null) return; // null means don't show

    comboBox.firePopupMenuWillBecomeVisible();
    show(comboBox, popupBounds.x, popupBounds.y);

    // hack for <rdar://problem/4905531> JComboBox does not fire popupWillBecomeVisible if item count is 0
    final int afterShowItemCount = comboBox.getItemCount();
    if (afterShowItemCount == 0) {
        hide();
        return;
    }

    if (startItemCount != afterShowItemCount) {
        final Rectangle newBounds = adjustPopupAndGetBounds();
        list.setSize(newBounds.width, newBounds.height);
        pack();

        final Point newLoc = comboBox.getLocationOnScreen();
        setLocation(newLoc.x + newBounds.x, newLoc.y + newBounds.y);
    }
    // end hack

    list.requestFocusInWindow();
}
 
Example 47
Project: LinkGame   File: DrawHelper.java   Source Code and License 5 votes vote down vote up
/** 绘制鼠标移入时节点的状态 */
public static void drawMoveRect(int[][] nodes, Point point, Graphics g) {
	if (point == null || nodes == null)
		return;
	int i = getI(point.y);
	int j = getJ(point.x);
	if (i < 1 || j < 1 || i > Constants.NODES_ROW - 2 || j > Constants.NODES_COLUMN - 2
			|| nodes[i][j] < 1 || nodes[i][j] > 20)
		return;
	g.setColor(Color.red);
	g.drawRect(getRealX(j), getRealY(i), Constants.NODE_WIDTH, Constants.NODE_WIDTH);
	g.drawRect(getRealX(j) - 2, getRealY(i) - 2, Constants.NODE_WIDTH + 4,
			Constants.NODE_WIDTH + 4);
}
 
Example 48
Project: parabuild-ci   File: ChartPanel.java   Source Code and License 5 votes vote down vote up
/**
 * Increases the length the range axis, centered about the given
 * coordinate on the screen.  The length of the range axis is increased
 * by the value of {@link #getZoomOutFactor()}.
 *
 * @param x  the x coordinate (in screen coordinates).
 * @param y  the y-coordinate (in screen coordinates).
 */
public void zoomOutRange(double x, double y) {
    Plot p = this.chart.getPlot();
    if (p instanceof Zoomable) {
        Zoomable z = (Zoomable) p;
        z.zoomRangeAxes(this.zoomOutFactor, this.info.getPlotInfo(), 
                translateScreenToJava2D(new Point((int) x, (int) y)));
    }
}
 
Example 49
Project: brModelo   File: PreEspecializacao.java   Source Code and License 5 votes vote down vote up
private void verifiqueOcupacao(PontoDeLinha ponto, Point p, int posi, Point pMeio) {
    RemovaOcupados(ponto);
    if (ocupados[posi] != null) {
        ponto.setCentro(pMeio);
    } else {
        ocupados[posi] = ponto;
        ponto.setCentro(p);
    }
}
 
Example 50
Project: openjdk-jdk10   File: InputSlot.java   Source Code and License 5 votes vote down vote up
@Override
public Point getRelativePosition() {
    int gap = getFigure().getWidth() - Figure.getSlotsWidth(getFigure().getInputSlots());
    double gapRatio = (double)gap / (double)(getFigure().getInputSlots().size() + 1);
    int gapAmount = (int)((getPosition() + 1)*gapRatio);
    return new Point(gapAmount + Figure.getSlotsWidth(Figure.getAllBefore(getFigure().getInputSlots(), this)) + getWidth()/2, -Figure.SLOT_START);
    //return new Point((getFigure().getWidth() / (getFigure().getInputSlots().size() * 2)) * (getPosition() * 2 + 1), -Figure.SLOT_START);
}
 
Example 51
Project: sbc-qsystem   File: FResponseDialog.java   Source Code and License 5 votes vote down vote up
/**
 * Статический метод который показывает модально диалог выбора времени для предварительной
 * записи клиентов.
 *
 * @param parent фрейм относительно которого будет модальность
 * @param respList XML-список возможных отзывов
 * @param modal модальный диалог или нет
 * @param fullscreen растягивать форму на весь экран и прятать мышку или нет
 * @param delay задержка перед скрытием диалога. если 0, то нет автозакрытия диалога
 * @return XML-описание результата предварительной записи, по сути это номерок. если null, то
 * отказались от предварительной записи
 */
public static QRespItem showResponseDialog(Frame parent, QRespItem respList, boolean modal,
    boolean fullscreen, int delay) {
    FResponseDialog.delay = delay;
    QLog.l().logger().info("Выбор отзыва");
    if (respDialog == null) {
        respDialog = new FResponseDialog(parent, modal);
        respDialog.setTitle(getLocaleMessage("dialog.title"));
    }
    respDialog.changeTextToLocale();
    FResponseDialog.setRoot(respList);
    result = null;
    Uses.setLocation(respDialog);
    respDialog.changeTextToLocale();
    if (!(QConfig.cfg().isDebug() || QConfig.cfg().isDemo() && !fullscreen)) {
        Uses.setFullSize(respDialog);
        if (QConfig.cfg().isHideCursor()) {
            int[] pixels = new int[16 * 16];
            Image image = Toolkit.getDefaultToolkit()
                .createImage(new MemoryImageSource(16, 16, pixels, 0, 16));
            Cursor transparentCursor = Toolkit.getDefaultToolkit()
                .createCustomCursor(image, new Point(0, 0), "invisibleCursor");
            respDialog.setCursor(transparentCursor);
        }

    } else {
        respDialog.setSize(1280, 768);
        Uses.setLocation(respDialog);
    }
    respDialog.showLevel(FResponseDialog.root);
    if (respDialog.clockBack.isActive()) {
        respDialog.clockBack.stop();
    }
    if (respDialog.clockBack.getInterval() > 1000) {
        respDialog.clockBack.start();
    }
    respDialog.setVisible(true);
    return result;
}
 
Example 52
Project: OpenJSharp   File: MetalToolBarUI.java   Source Code and License 5 votes vote down vote up
protected void setDragOffset(Point p) {
    if (!GraphicsEnvironment.isHeadless()) {
        if (dragWindow == null) {
            dragWindow = createDragWindow(toolBar);
        }
        dragWindow.setOffset(p);
    }
}
 
Example 53
Project: JDigitalSimulator   File: ByteToDecimalConverter.java   Source Code and License 5 votes vote down vote up
public ByteToDecimalConverter() {
	size = new Dimension(75, 85);
	inputs = new InputContact[4];
	for(int input=0;input<inputs.length;input++)
		inputs[input] = new InputContact(this);
	ContactList.setContactLocations(this, inputs);
	outputs = new OutputContact[16];
	for(int output=0;output<outputs.length;output++)
		outputs[output] = new OutputContact(this);
	contacts = ContactUtilities.concatenateContacts(inputs, outputs);
	ContactList.setContactLocations(this, outputs, new Point(size.width, 0));
}
 
Example 54
Project: jdk8u-jdk   File: SunWritableRaster.java   Source Code and License 5 votes vote down vote up
public SunWritableRaster(SampleModel sampleModel,
                         DataBuffer dataBuffer,
                         Point origin)
{
    super(sampleModel, dataBuffer, origin);
    theTrackable = stealTrackable(dataBuffer);
}
 
Example 55
Project: rapidminer   File: ToolBarUI.java   Source Code and License 5 votes vote down vote up
protected void setDragOffset(Point p) {
	if (!GraphicsEnvironment.isHeadless()) {
		if (this.dragWindow == null) {
			this.dragWindow = createDragWindow(this.toolBar);
		}
		this.dragWindow.setOffset(p);
	}
}
 
Example 56
Project: incubator-netbeans   File: SlideGestureRecognizer.java   Source Code and License 5 votes vote down vote up
/** @return Area in which automatic slide in is preserved. Can return
 * null signalizing that components making active area bounds are not yet 
 * ready or showing.
 */
private Rectangle computeActiveArea() {
    Component slidedComp = slideBar.getSlidedComp();
    if (slidedComp == null || !slidedComp.isShowing()) {
        return null;
    }
    
    Point slideBarLoc = slideBar.getLocationOnScreen();
    Rectangle actArea = new Rectangle(slideBarLoc.x - 1, slideBarLoc.y - 1,
                            slideBar.getWidth() - 1, slideBar.getHeight() - 1);
    
    Point slidedCompLoc = slidedComp.getLocationOnScreen();
    
    int slidex = slidedCompLoc.x;
    int slidey = slidedCompLoc.y;
    int slideh = slidedComp.getHeight();
    int slidew = slidedComp.getWidth();
    int orientation = slideBar.getModel().getOrientation();
    if (orientation == SlideBarDataModel.WEST) {
        slidew = slidew + ResizeGestureRecognizer.RESIZE_BUFFER;
    }
    if (orientation == SlideBarDataModel.EAST) {
        slidew = slidew + ResizeGestureRecognizer.RESIZE_BUFFER;
        slidex = slidex - ResizeGestureRecognizer.RESIZE_BUFFER;
    }
    if (orientation == SlideBarDataModel.SOUTH) {
        slideh = slideh + ResizeGestureRecognizer.RESIZE_BUFFER;
        slidey = slidey - ResizeGestureRecognizer.RESIZE_BUFFER;
    }
    if (orientation == SlideBarDataModel.NORTH) {
        slideh = slideh + ResizeGestureRecognizer.RESIZE_BUFFER;
    }
    actArea = SwingUtilities.computeUnion(
        slidex, slidey, slidew,
        slideh, actArea);
    
    return actArea;
}
 
Example 57
Project: openjdk-jdk10   File: IntegerComponentRaster.java   Source Code and License 5 votes vote down vote up
/**
 * Creates a subraster given a region of the raster.  The x and y
 * coordinates specify the horizontal and vertical offsets
 * from the upper-left corner of this raster to the upper-left corner
 * of the subraster.  A subset of the bands of the parent Raster may
 * be specified.  If this is null, then all the bands are present in the
 * subRaster. A translation to the subRaster may also be specified.
 * Note that the subraster will reference the same
 * DataBuffer as the parent raster, but using different offsets.
 * @param x               X offset.
 * @param y               Y offset.
 * @param width           Width (in pixels) of the subraster.
 * @param height          Height (in pixels) of the subraster.
 * @param x0              Translated X origin of the subraster.
 * @param y0              Translated Y origin of the subraster.
 * @param bandList        Array of band indices.
 * @exception RasterFormatException
 *            if the specified bounding box is outside of the parent raster.
 */
public WritableRaster createWritableChild (int x, int y,
                                           int width, int height,
                                           int x0, int y0,
                                           int bandList[]) {
    if (x < this.minX) {
        throw new RasterFormatException("x lies outside raster");
    }
    if (y < this.minY) {
        throw new RasterFormatException("y lies outside raster");
    }
    if ((x+width < x) || (x+width > this.minX + this.width)) {
        throw new RasterFormatException("(x + width) is outside raster");
    }
    if ((y+height < y) || (y+height > this.minY + this.height)) {
        throw new RasterFormatException("(y + height) is outside raster");
    }

    SampleModel sm;

    if (bandList != null)
        sm = sampleModel.createSubsetSampleModel(bandList);
    else
        sm = sampleModel;

    int deltaX = x0 - x;
    int deltaY = y0 - y;

    return new IntegerComponentRaster(sm,
                                      (DataBufferInt) dataBuffer,
                                      new Rectangle(x0,y0,width,height),
                                      new Point(sampleModelTranslateX+deltaX,
                                                sampleModelTranslateY+deltaY),
                                      this);
}
 
Example 58
Project: Lucid2.0   File: MapleMap.java   Source Code and License 5 votes vote down vote up
public final SpawnPoint addMonsterSpawn(final MapleMonster monster, final int mobTime, final byte carnivalTeam, final String msg) {
    final Point newpos = calcPointBelow(monster.getPosition());
    newpos.y -= 1;
    final SpawnPoint sp = new SpawnPoint(monster, newpos, mobTime, carnivalTeam, msg);
    if (carnivalTeam > -1) {
        monsterSpawn.add(0, sp); //at the beginning
    } else {
        monsterSpawn.add(sp);
    }
    return sp;
}
 
Example 59
Project: VASSAL-src   File: HexGrid.java   Source Code and License 4 votes vote down vote up
/**
 * Return the Shape of a single hex
 * @param centerX X co-ord of hex centre
 * @param centerY Y co-ord of hex centre
 * @return Hex Shape
 */
protected Area getSingleHexShape(int centerX, int centerY, boolean reversed) {
  Polygon poly = new Polygon();

  float x = (float) (sideways ? centerY : centerX);
  float y = (float) (sideways ? centerX : centerY);

  float x1,y1, x2,y2, x3,y3, x4, y4, x5, y5, x6, y6;

  float deltaX = (float) (this.dx);
  float deltaY = (float) (this.dy);

  float r = 2.F * deltaX / 3.F;

  Point p1 = new Point();
  Point p2 = new Point();
  Point p3 = new Point();
  Point p4 = new Point();
  Point p5 = new Point();
  Point p6 = new Point();

  x1 = x - r;
  y1 = y;
  p1.setLocation(round(x1), round(y1));

  x2 = x - 0.5F * r;
  y2 = reversed ? y + 0.5F * deltaY : y - 0.5F * deltaY;
  p2.setLocation(round(x2), round(y2));

  x3 = x + 0.5F * r;
  y3 = y2;
  p3.setLocation(round(x3) + 1, round(y3));

  x4 = x + r;
  y4 = y;
  p4.setLocation(round(x4) + 1, round(y4));

  x5 = x3;
  y5 = reversed ? y - 0.5F * deltaY : y + 0.5F * deltaY;
  p5.setLocation(round(x5) + 1, round(y5) + 1);

  x6 = x2;
  y6 = y5;
  p6.setLocation(round(x6), round(y6) + 1);

  if (sideways) {
    rotate(p1);
    rotate(p2);
    rotate(p3);
    rotate(p4);
    rotate(p5);
    rotate(p6);
  }

  poly.addPoint(p1.x, p1.y);
  poly.addPoint(p2.x, p2.y);
  poly.addPoint(p3.x, p3.y);
  poly.addPoint(p4.x, p4.y);
  poly.addPoint(p5.x, p5.y);
  poly.addPoint(p6.x, p6.y);
  poly.addPoint(p1.x, p1.y);

  return new Area(poly);
}
 
Example 60
Project: openjdk-jdk10   File: ThemeReader.java   Source Code and License 4 votes vote down vote up
public static Point getPoint(String widget, int part, int state, int property) {
    return null;
}