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:com.orsonpdf.demo.PDFPieChartDemo1.java

/**
 * Creates a chart.//from w w  w  .ja va2s.  c om
 *
 * @param dataset  the dataset.
 *
 * @return A chart.
 */
private static JFreeChart createChart(PieDataset dataset) {

    JFreeChart chart = ChartFactory.createPieChart("Smart Phones Manufactured / Q3 2011", dataset, false, false,
            false);

    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);
    plot.setShadowPaint(null);
    plot.setLabelShadowPaint(null);

    // 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);
    BasicStroke bs = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER, 1.0f);
    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("Source: http://www.bbc.co.uk/news/business-15489523",
            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:net.sf.maltcms.chromaui.charts.labels.TopKItemsLabelGenerator.java

/**
 *
 * @param arg0//from w w w . j  a  v  a  2  s .c om
 * @param arg1
 * @param arg2
 * @return
 */
@Override
public String generateLabel(XYDataset arg0, int arg1, int arg2) {
    if (this.topK.contains(new Point(arg1, arg2))) {
        StringBuilder sb = new StringBuilder();
        sb.append(String.format("%.4f", arg0.getXValue(arg1, arg2)));
        return sb.toString();
    }

    return null;
}

From source file:SaveYourDrawingToFile.java

public void mouseReleased(MouseEvent e) {
    Point p = new Point(e.getX(), e.getY());
    displayList.add(p);
    repaint();
}

From source file:Bezier.java

/**
 * Creates a new Bezier curve./*  ww  w .jav  a 2 s.  c om*/
 * @param points
 */
public Bezier(Point2D[] points) {
    int n = points.length;
    if (n < 3) {
        // Cannot create bezier with less than 3 points
        return;
    }
    bPoints = new Point[2 * (n - 2)];
    double paX, paY;
    double pbX = points[0].getX();
    double pbY = points[0].getY();
    double pcX = points[1].getX();
    double pcY = points[1].getY();
    for (int i = 0; i < n - 2; i++) {
        paX = pbX;
        paY = pbY;
        pbX = pcX;
        pbY = pcY;
        pcX = points[i + 2].getX();
        pcY = points[i + 2].getY();
        double abX = pbX - paX;
        double abY = pbY - paY;
        double acX = pcX - paX;
        double acY = pcY - paY;
        double lac = Math.sqrt(acX * acX + acY * acY);
        acX = acX / lac;
        acY = acY / lac;

        double proj = abX * acX + abY * acY;
        proj = proj < 0 ? -proj : proj;
        double apX = proj * acX;
        double apY = proj * acY;

        double p1X = pbX - AP * apX;
        double p1Y = pbY - AP * apY;
        bPoints[2 * i] = new Point((int) p1X, (int) p1Y);

        acX = -acX;
        acY = -acY;
        double cbX = pbX - pcX;
        double cbY = pbY - pcY;
        proj = cbX * acX + cbY * acY;
        proj = proj < 0 ? -proj : proj;
        apX = proj * acX;
        apY = proj * acY;

        double p2X = pbX - AP * apX;
        double p2Y = pbY - AP * apY;
        bPoints[2 * i + 1] = new Point((int) p2X, (int) p2Y);
    }
}

From source file:de.tud.kom.p2psim.impl.application.ido.moveModels.RandomMoveModel.java

@Override
public Point getNextPosition(IDOApplication app) {
    RandomGenerator r = Simulator.getRandom();

    Point pos = app.getPlayerPosition();

    Point newPos;//from   w  w  w  . j  av  a  2s  . c  o  m

    if (portal != null) {
        Point position = portal.portal(app.getPlayerPosition(), app, worldDimensionX, worldDimensionY);
        // if a portal is used.
        if (position != null) {
            return position;
        }
    }

    do {
        newPos = new Point(pos.x + (r.nextInt(2 * moveSpeedLimit + 1) - moveSpeedLimit),
                pos.y + (r.nextInt(2 * moveSpeedLimit + 1) - moveSpeedLimit));

    } while (newPos.x < 0 || newPos.x > worldDimensionX || newPos.y < 0 || newPos.y > worldDimensionY);
    setMoveVector(app, newPos);
    return newPos;
}

From source file:GUIUtils.java

/**
 * Centers passed internal frame within its desktop area. If centering would
 * cause the title bar to go off the top of the screen then move the window
 * down.//from  ww  w  .j  a  v a  2 s. c o  m
 * 
 * @param frame
 *          The internal frame to be centered.
 * 
 * @throws IllegalArgumentException
 *           If <TT>frame</TT> is <TT>null</TT>.
 */
public static void centerWithinDesktop(JInternalFrame frame) {
    if (frame == null) {
        throw new IllegalArgumentException("null JInternalFrame passed");
    }
    final Container parent = frame.getDesktopPane();
    if (parent != null && parent.isVisible()) {
        center(frame, new Rectangle(new Point(0, 0), parent.getSize()));
    }
}

From source file:de.dakror.villagedefense.game.entity.creature.Creature.java

public Creature(int x, int y, String img) {
    super(x, y, Game.getImage("creature/" + img + ".png").getWidth() / 4,
            Game.getImage("creature/" + img + ".png").getHeight() / 4);

    spawnPoint = new Point(x, y);

    image = Game.getImage("creature/" + img + ".png");

    setBump(new Rectangle((int) (width * 0.25f), (int) (height * 0.75f), (int) (width * 0.5f),
            (int) (height * 0.25f)));
    frozen = false;/*from   w  ww . j a v a  2 s .  com*/

    dir = 0;
    frame = 0;
}

From source file:simMPLS.scenario.TNode.java

/**
 * Crea una nueva instancia de TNodoTopologia.
 * @since 1.0//from   ww w .  j a  va2 s  .c  om
 * @param identificador Identificador unico para el nodo en la topology.
 * @param d Direccin IP del nodo.
 * @param il Generador de identificadores para los eventos que deba emitir el nodo.
 * @param t Topologia donde se encuentra el nodo includo.
 */
public TNode(int identificador, String d, TLongIDGenerator il, TTopology t) {
    super(TTopologyElement.NODO, il);
    posicion = new Point(0, 0);
    id = identificador;
    nombre = "";
    estado = DESELECCIONADO;
    mostrarNombre = false;
    IP = d;
    mask = "255.255.255.255";
    ports = null;
    cerrojo = new TMonitor();
    topology = t;
    generarEstadisticas = false;
    availableNs = 0;
    nsDelTic = 0;
    pasosSinEmitir = 0;
    sayCongested = false;
    LDP = true;
}

From source file:org.mwc.cmap.grideditor.chart.RendererWithDynamicFeedback.java

public void setFeedbackSubject(final int row, final int column) {
    myFeedBackRowAndColumn = new Point(row, column);
}

From source file:modelibra.designer.metaconceptgraphic.MetaConceptGraphic.java

public Point getLocation() {
    Integer xInteger = getX();
    Integer yInteger = getY();
    return new Point(xInteger, yInteger);
}