Example usage for java.awt Point Point

List of usage examples for java.awt Point Point

Introduction

In this page you can find the example usage for java.awt Point Point.

Prototype

public Point(int x, int y) 

Source Link

Document

Constructs and initializes a point at the specified (x,y) location in the coordinate space.

Usage

From source file:UserInterface.PublisherRole.ViewUserHabitsJPanel.java

private static JFreeChart createChart(PieDataset dataset) {

    JFreeChart chart = ChartFactory.createPieChart("User Habits", // chart title
            dataset, // data
            false, // no legend
            true, // tooltips
            false // no URL generation
    );//from   ww  w . j a  v  a  2 s .  c om

    // set a custom background for the chart
    chart.setBackgroundPaint(
            new GradientPaint(new Point(0, 0), new Color(20, 20, 20), new Point(400, 200), Color.DARK_GRAY));

    // customise the title position and font
    TextTitle t = chart.getTitle();
    t.setHorizontalAlignment(HorizontalAlignment.LEFT);
    t.setPaint(new Color(240, 240, 240));
    t.setFont(new Font("Arial", Font.BOLD, 26));

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setBackgroundPaint(null);
    plot.setInteriorGap(0.04);
    plot.setOutlineVisible(false);

    // use gradients and white borders for the section colours
    plot.setSectionPaint("Others", createGradientPaint(new Color(200, 200, 255), Color.BLUE));
    plot.setSectionPaint("Samsung", createGradientPaint(new Color(255, 200, 200), Color.RED));
    plot.setSectionPaint("Apple", createGradientPaint(new Color(200, 255, 200), Color.GREEN));
    plot.setSectionPaint("Nokia", createGradientPaint(new Color(200, 255, 200), Color.YELLOW));
    plot.setBaseSectionOutlinePaint(Color.WHITE);
    plot.setSectionOutlinesVisible(true);
    plot.setBaseSectionOutlineStroke(new BasicStroke(2.0f));

    // customise the section label appearance
    plot.setLabelFont(new Font("Courier New", Font.BOLD, 20));
    plot.setLabelLinkPaint(Color.WHITE);
    plot.setLabelLinkStroke(new BasicStroke(2.0f));
    plot.setLabelOutlineStroke(null);
    plot.setLabelPaint(Color.WHITE);
    plot.setLabelBackgroundPaint(null);

    // add a subtitle giving the data source
    TextTitle source = new TextTitle(" ", new Font("Courier New", Font.PLAIN, 12));
    source.setPaint(Color.WHITE);
    source.setPosition(RectangleEdge.BOTTOM);
    source.setHorizontalAlignment(HorizontalAlignment.RIGHT);
    chart.addSubtitle(source);
    return chart;

}

From source file:ca.sqlpower.architect.swingui.TestPlayPen.java

public void testUndoAddTable() throws SQLObjectException {
    SQLTable t = new SQLTable(ppdb, "test_me", "", "TABLE", true);

    TablePane tp = new TablePane(t, pp.getContentPane());
    ppdb.addChild(t);/*from   ww w.  j a  v  a 2  s. c o  m*/

    pp.addTablePane(tp, new Point(99, 98));

    // this isn't the point of the test, but adding the tablepane has to work!
    assertNotNull(pp.findTablePane(t));

    //Undo the add child and the move table pane
    session.getUndoManager().undo();

    assertNull(pp.findTablePane(t));
}

From source file:ded.model.Entity.java

public Entity() {
    this.loc = new Point(0, 0);
    this.size = new Dimension(100, 50);
}

From source file:main.java.gui.java

private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    // Generated using JFormDesigner Evaluation license - BOHDAN Korinnyi
    test = new JFrame();
    label1 = new JLabel();
    textField1 = new JTextField();
    label2 = new JLabel();
    textField2 = new JTextField();
    label3 = new JLabel();
    label4 = new JLabel();
    textField3 = new JTextField();
    textField4 = new JTextField();
    button1 = new JButton();
    button2 = new JButton();
    label5 = new JLabel();
    label6 = new JLabel();

    //======== test ========
    {/*from ww  w.j a  v  a 2s .c om*/
        test.setTitle("Pay mobile account");
        Container testContentPane = test.getContentPane();
        testContentPane.setLayout(null);

        //---- label1 ----
        label1.setText("\u0421\u0443\u043c\u0430");
        label1.setFont(label1.getFont().deriveFont(label1.getFont().getSize() + 4f));
        testContentPane.add(label1);
        label1.setBounds(new Rectangle(new Point(35, 30), label1.getPreferredSize()));

        //---- textField1 ----
        textField1.setColumns(10);
        testContentPane.add(textField1);
        textField1.setBounds(150, 30, 105, textField1.getPreferredSize().height);

        //---- label2 ----
        label2.setText("\u041d\u043e\u043c\u0435\u0440");
        label2.setFont(label2.getFont().deriveFont(label2.getFont().getSize() + 4f));
        testContentPane.add(label2);
        label2.setBounds(new Rectangle(new Point(35, 60), label2.getPreferredSize()));

        //---- textField2 ----
        textField2.setText("0674060606");
        textField2.setFont(textField2.getFont().deriveFont(textField2.getFont().getSize() + 2f));
        testContentPane.add(textField2);
        textField2.setBounds(150, 60, 105, textField2.getPreferredSize().height);

        //---- label3 ----
        label3.setText("\u041b\u043e\u0433\u0456\u043d");
        label3.setFont(label3.getFont().deriveFont(label3.getFont().getSize() + 4f));
        testContentPane.add(label3);
        label3.setBounds(new Rectangle(new Point(35, 95), label3.getPreferredSize()));

        //---- label4 ----
        label4.setText("\u041f\u0430\u0440\u043e\u043b\u044c");
        label4.setFont(label4.getFont().deriveFont(label4.getFont().getSize() + 4f));
        testContentPane.add(label4);
        label4.setBounds(new Rectangle(new Point(35, 125), label4.getPreferredSize()));
        testContentPane.add(textField3);
        textField3.setBounds(150, 95, 105, textField3.getPreferredSize().height);
        testContentPane.add(textField4);
        textField4.setBounds(150, 125, 105, 20);

        //---- button1 ----
        button1.setText("\u041e\u043f\u043b\u0430\u0442\u0438\u0442\u0438");
        button1.setFont(button1.getFont().deriveFont(button1.getFont().getStyle() | Font.BOLD,
                button1.getFont().getSize() + 2f));
        button1.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                String strTemp = textField1.getText();
                int cash = Integer.parseInt(strTemp);
                if (cash < 1) {
                    JOptionPane.showMessageDialog(null, "    '", "",
                            JOptionPane.OK_OPTION);
                    textField1.setText("0");
                } else if (textField3.getText().equals("test4") && textField4.getText().equals("12345")) {
                    check c = new check();
                    pay p = new pay();
                    getstatus g = new getstatus();
                    try {
                        c.connection(c.PaymentCollectionRequest("38" + getNumber(), getMoney()));
                        g.connection(c.PaymentStatusRequest());
                        p.connection(c.PaymentCollectionRequest("38" + getNumber(), getMoney()));
                        g.connection(c.PaymentStatusRequest());
                        information i = new information();
                        daoImplements h = new daoImplements();
                        long curTime = System.currentTimeMillis();
                        String curStringDate = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss").format(curTime);

                        i.setIdTransaction(getTransaction.setGetTransaction());
                        i.setData(curStringDate);
                        i.setNumber(Integer.parseInt(getNumber()));
                        i.setSuma(Integer.parseInt(getMoney()));
                        i.setStatus(parserStatus.getStatusParsing());
                        h.addInfo(i);

                    } catch (IOException e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
                    } catch (ParseException e2) {
                        // TODO Auto-generated catch block
                        e2.printStackTrace();
                    }
                } else {
                    JOptionPane.showMessageDialog(null, "    ", "",
                            JOptionPane.OK_OPTION);
                    System.exit(0);
                }
            }

        });
        testContentPane.add(button1);
        button1.setBounds(150, 155, 115, 25);

        //---- button2 ----
        button2.setText("\u0406\u0441\u0442\u043e\u0440\u0456\u044f");
        button2.setFont(button2.getFont().deriveFont(button2.getFont().getStyle() | Font.BOLD,
                button2.getFont().getSize() + 2f));
        button2.setActionCommand("\u0406\u0441\u0442\u043e\u0440\u0456\u044f");
        button2.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                tableData t = new tableData();
            }
        });
        testContentPane.add(button2);
        button2.setBounds(15, 155, 115, 25);

        //---- label5 ----
        label5.setText(
                "\u0422\u0435\u0441\u0442\u043e\u0432\u0438\u0439 \u0441\u0435\u0440\u0432\u0456\u0441 \u043f\u043e\u043f\u043e\u0432\u043d\u0435\u043d\u043d\u044f \u043c\u043e\u0431\u0456\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0430\u0445\u0443\u043d\u043a\u0443");
        label5.setFont(label5.getFont().deriveFont(label5.getFont().getStyle() & ~Font.ITALIC));
        testContentPane.add(label5);
        label5.setBounds(15, 0, 255, 20);

        //---- label6 ----
        label6.setText("38");
        label6.setFont(label6.getFont().deriveFont(label6.getFont().getSize() + 4f));
        testContentPane.add(label6);
        label6.setBounds(new Rectangle(new Point(130, 60), label6.getPreferredSize()));

        { // compute preferred size
            Dimension preferredSize = new Dimension();
            for (int i = 0; i < testContentPane.getComponentCount(); i++) {
                Rectangle bounds = testContentPane.getComponent(i).getBounds();
                preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
                preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
            }
            Insets insets = testContentPane.getInsets();
            preferredSize.width += insets.right;
            preferredSize.height += insets.bottom;
            testContentPane.setMinimumSize(preferredSize);
            testContentPane.setPreferredSize(preferredSize);
        }
        test.pack();
        test.setLocationRelativeTo(test.getOwner());
    }
    // JFormDesigner - End of component initialization  //GEN-END:initComponents
}

From source file:components.RootLayeredPaneDemo.java

public RootLayeredPaneDemo(JLayeredPane layeredPane) {
    super(new GridLayout(1, 1));

    //Create and load the duke icon.
    final ImageIcon icon = createImageIcon("images/dukeWaveRed.gif");

    //Create and set up the layered pane.
    this.layeredPane = layeredPane;
    layeredPane.addMouseMotionListener(this);

    //This is the origin of the first label added.
    Point origin = new Point(10, 100);

    //This is the offset for computing the origin for the next label.
    int offset = 35;

    //Add several overlapping, colored labels to the layered pane
    //using absolute positioning/sizing.
    for (int i = 0; i < layerStrings.length; i++) {
        JLabel label = createColoredLabel(layerStrings[i], layerColors[i], origin);
        layeredPane.add(label, new Integer(layers[i]));
        origin.x += offset;//from w  w w .  j ava  2  s .c  o m
        origin.y += offset;
    }

    //Create and add the Duke label to the layered pane.
    dukeLabel = new JLabel(icon);
    if (icon != null) {
        dukeLabel.setBounds(15, 225, icon.getIconWidth(), icon.getIconHeight());
    } else {
        System.err.println("Duke icon not found; using black square instead.");
        dukeLabel.setBounds(15, 225, 30, 30);
        dukeLabel.setOpaque(true);
        dukeLabel.setBackground(Color.BLACK);
    }
    layeredPane.add(dukeLabel, new Integer(layers[INITIAL_DUKE_LAYER_INDEX]), 0);

    //Add control pane to this JPanel.
    add(createControlPanel());
}

From source file:fr.landel.utils.commons.CollectionUtils2Test.java

/**
 * Test method for//from  www  . j a  va  2s . c  o m
 * {@link CollectionUtils2#transformIntoList(java.lang.Iterable, Transformer)}
 * {@link CollectionUtils2#transformIntoList(java.lang.Iterable, Function)}
 * .
 */
@Test
public void testTransformIntoListIterableOfITransformerOfIO() {
    try {
        List<Point> points = new ArrayList<>();
        points.add(new Point(1, 2));
        points.add(new Point(2, 0));
        points.add(null);

        List<String> strPoints = CollectionUtils2.transformIntoList(points, TRANSFORMER);

        assertThat(strPoints, Matchers.contains("1, 2", "2, 0", null));

        strPoints = CollectionUtils2.transformIntoList(points, FUNCTION);

        assertThat(strPoints, Matchers.contains("1, 2", "2, 0", null));
    } catch (IllegalArgumentException e) {
        fail("The test isn't correct");
    }
}

From source file:Main.java

/**
 * Computes the center point of the current screen device. If this method is called on JDK 1.4, Xinerama-aware
 * results are returned. (See Sun-Bug-ID 4463949 for details).
 *
 * @return the center point of the current screen.
 *///from  www .j a  v  a 2s . c o m
public static Point getCenterPoint() {
    final GraphicsEnvironment localGraphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
    try {
        final Method method = GraphicsEnvironment.class.getMethod("getCenterPoint", (Class[]) null);
        return (Point) method.invoke(localGraphicsEnvironment, (Object[]) null);
    } catch (Exception e) {
        // ignore ... will fail if this is not a JDK 1.4 ..
    }

    final Dimension s = Toolkit.getDefaultToolkit().getScreenSize();
    return new Point(s.width / 2, s.height / 2);
}

From source file:components.LayeredPaneDemo.java

public LayeredPaneDemo() {
    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));

    //Create and load the duke icon.
    final ImageIcon icon = createImageIcon("images/dukeWaveRed.gif");

    //Create and set up the layered pane.
    layeredPane = new JLayeredPane();
    layeredPane.setPreferredSize(new Dimension(300, 310));
    layeredPane.setBorder(BorderFactory.createTitledBorder("Move the Mouse to Move Duke"));
    layeredPane.addMouseMotionListener(this);

    //This is the origin of the first label added.
    Point origin = new Point(10, 20);

    //This is the offset for computing the origin for the next label.
    int offset = 35;

    //Add several overlapping, colored labels to the layered pane
    //using absolute positioning/sizing.
    for (int i = 0; i < layerStrings.length; i++) {
        JLabel label = createColoredLabel(layerStrings[i], layerColors[i], origin);
        layeredPane.add(label, new Integer(i));
        origin.x += offset;/*from w  w w . j av  a2 s  .c o  m*/
        origin.y += offset;
    }

    //Create and add the Duke label to the layered pane.
    dukeLabel = new JLabel(icon);
    if (icon != null) {
        dukeLabel.setBounds(15, 225, icon.getIconWidth(), icon.getIconHeight());
    } else {
        System.err.println("Duke icon not found; using black square instead.");
        dukeLabel.setBounds(15, 225, 30, 30);
        dukeLabel.setOpaque(true);
        dukeLabel.setBackground(Color.BLACK);
    }
    layeredPane.add(dukeLabel, new Integer(2), 0);

    //Add control pane and layered pane to this JPanel.
    add(Box.createRigidArea(new Dimension(0, 10)));
    add(createControlPanel());
    add(Box.createRigidArea(new Dimension(0, 10)));
    add(layeredPane);
}

From source file:Main.java

/**
 * Returns an appropriate location for a component's tool tip that <i>always</i>
 * lies within the specified frame./*  w  w w  .ja  va 2  s.c  om*/
 * <p>
 * Intended be used in custom implementations of {@link JComponent#getToolTipLocation(MouseEvent)}.
 *
 * @param e
 *          the event that caused the display of the tool tip
 * @param c
 *          the parent component of the tool tip
 * @param frame
 *          a component in which the tool tip has to fit (usually the surrounding window of "c")
 * @return
 */
public static Point getAdjustedToolTipLocation(MouseEvent e, JComponent c, Component frame) {
    JToolTip tip = new JToolTip();
    tip.setTipText(c.getToolTipText(e));
    Dimension tipSize = tip.getPreferredSize();
    // Tool tip will be positioned within the bounds of the specified component (+ 5px inset)
    Rectangle frameR = frame.getBounds();
    if (frame instanceof Container) {
        Container container = (Container) frame;
        Insets insets = container.getInsets();
        frameR.x += insets.left;
        frameR.y += insets.top;
        frameR.width -= (insets.left + insets.right);
        frameR.height -= (insets.top + insets.bottom);
    }
    frameR.x += 5;
    frameR.y += 5;
    frameR.width -= 10;
    frameR.height -= 10;
    // Initial try for the tool tip's position
    Rectangle r = new Rectangle(e.getXOnScreen(), c.getLocationOnScreen().y + c.getSize().height + 1,
            tipSize.width, tipSize.height);
    // Check if it fits within the frame
    Rectangle intersection = frameR.intersection(r);
    if (r.equals(intersection)) {
        // Tool tip is fully visible within the frame --> use default behaviour
        //
        // Note: The implementation of ToolTipManager.showTipWindow() is not always
        // correct in dual screen mode. The tool tip is _always_ put on that screen,
        // where the most part of the frame lies upon, even if we return coordinates
        // that clearly belong to the other screen. Unfortunately we cannot change
        // that behavior... (bsh 2010-11-24)
        return null;
    }
    // Otherwise, move the tool tip
    int correction = 0;
    if (r.height == intersection.height) {
        // Height is okay, just move left. To make it look better, position the
        // tip 5px below the component.
        r = new Rectangle(r.x, c.getLocationOnScreen().y + c.getSize().height + 5, tipSize.width,
                tipSize.height);
        correction = -5; // needed to make the ToolTipManager use a lightweight pop-up
    } else {
        // The height does not fit. Position the tool tip above the component.
        r = new Rectangle(c.getLocationOnScreen().x + 10, c.getLocationOnScreen().y - tipSize.height - 1,
                tipSize.width, tipSize.height);
    }
    // Adjust to frame bounds
    intersection = frameR.intersection(r);
    intersection.x -= (r.width - intersection.width);
    intersection.y -= (r.height - intersection.height);
    // Return value is expected to be relative to the component's position
    return new Point((-c.getLocationOnScreen().x) + intersection.x + correction,
            (-c.getLocationOnScreen().y) + intersection.y);
}

From source file:it.unibas.spicygui.controllo.tree.ActionAddMappingInCompositionScene.java

public void actionPerformed(ActionEvent e) {
    DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) albero.getLastSelectedPathComponent();
    TreeTopComponentAdapter adapter = (TreeTopComponentAdapter) treeNode.getUserObject();
    Scenario scenarioTreeSelected = adapter.getScenario();
    WidgetCreator widgetCreator = new WidgetCreator();
    Scenario currentScenarioSelected = (Scenario) modello.getBean(Costanti.CURRENT_SCENARIO);
    if (currentScenarioSelected != null && currentScenarioSelected.getCompositionTopComponent() != null) {
        CompositionTopComponent compositionTopComponent = currentScenarioSelected.getCompositionTopComponent();

        Widget widget = widgetCreator.createConstantWidget(compositionTopComponent.getGlassPane().getScene(),
                compositionTopComponent.getGlassPane().getMainLayer(),
                compositionTopComponent.getGlassPane().getConnectionLayer(), new Point(10, 10),
                compositionTopComponent.getGlassPane(), scenarioTreeSelected);
        if (widget == null) {
            StatusDisplayer.getDefault()
                    .setStatusText(NbBundle.getMessage(Costanti.class, Costanti.NOT_ADDED_IN_COMPOSITION));
        }/*from   w  w  w .ja v a2s . c om*/

        //            widgetCreator.createConstantWidget(compositionTopComponent.getGlassPane().getScene(), compositionTopComponent.getGlassPane().getMainLayer(), compositionTopComponent.getGlassPane().getConnectionLayer(), new Point(10, 10), compositionTopComponent.getGlassPane());
        compositionTopComponent.getGlassPane().getScene().validate();
        //            scenarioSelected.setInComposition(true);
    } else {
        StatusDisplayer.getDefault()
                .setStatusText(NbBundle.getMessage(Costanti.class, Costanti.NOT_ADDED_IN_COMPOSITION));
    }
}