Example usage for java.awt Font PLAIN

List of usage examples for java.awt Font PLAIN

Introduction

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

Prototype

int PLAIN

To view the source code for java.awt Font PLAIN.

Click Source Link

Document

The plain style constant.

Usage

From source file:hudson.plugins.robot.graph.RobotGraph.java

/**
 * Creates a Robot trend graph/*from   ww  w. j  av a  2 s .  c  om*/
 * @return the JFreeChart graph object
 */
protected JFreeChart createGraph() {

    final JFreeChart chart = ChartFactory.createStackedAreaChart(null, null, yLabel, categoryDataset,
            PlotOrientation.VERTICAL, true, true, false);

    final LegendTitle legend = chart.getLegend();
    legend.setPosition(RectangleEdge.RIGHT);

    chart.setBackgroundPaint(Color.white);

    final CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setForegroundAlpha(0.7f);
    plot.setBackgroundPaint(Color.white);
    plot.setRangeGridlinePaint(Color.darkGray);

    final CategoryAxis domainAxis = new ShiftedCategoryAxis(xLabel);
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    domainAxis.setCategoryMargin(0.0);
    plot.setDomainAxis(domainAxis);

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    if (binaryData) {
        rangeAxis.setUpperBound(1);
    } else if (upperBound != 0) {
        rangeAxis.setUpperBound(upperBound);
    } else {
        rangeAxis.setAutoRange(true);
    }
    rangeAxis.setLowerBound(lowerBound);
    Font font = new Font("Dialog", Font.PLAIN, fontSize);
    plot.getDomainAxis().setLabelFont(font);
    plot.getDomainAxis().setTickLabelFont(font);
    plot.getRangeAxis().setLabelFont(font);
    plot.getRangeAxis().setTickLabelFont(font);
    legend.setItemFont(font);
    final CategoryItemRenderer renderer = plot.getRenderer();

    for (int i = 0; i < colors.length; i++) {
        renderer.setSeriesPaint(i, colors[i]);
    }

    plot.setInsets(new RectangleInsets(15.0, 0, 0, 5.0));

    return chart;
}

From source file:org.jfree.chart.demo.MultiplePieChartDemo2.java

/**
 * Creates a sample chart with the given dataset.
 * /* www. ja  va2  s.  co  m*/
 * @param dataset  the dataset.
 * 
 * @return A sample chart.
 */
private JFreeChart createChart(final CategoryDataset dataset) {
    final JFreeChart chart = ChartFactory.createMultiplePieChart("Multiple Pie Chart", // chart title
            dataset, // dataset
            TableOrder.BY_COLUMN, true, // include legend
            true, false);
    final MultiplePiePlot plot = (MultiplePiePlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setOutlineStroke(new BasicStroke(1.0f));
    final JFreeChart subchart = plot.getPieChart();
    final PiePlot p = (PiePlot) subchart.getPlot();
    p.setBackgroundPaint(null);
    p.setOutlineStroke(null);
    p.setLabelGenerator(new StandardPieItemLabelGenerator("{0} ({2})", NumberFormat.getNumberInstance(),
            NumberFormat.getPercentInstance()));
    p.setMaximumLabelWidth(0.35);
    p.setLabelFont(new Font("SansSerif", Font.PLAIN, 9));
    p.setInteriorGap(0.30);
    return chart;
}

From source file:org.fhaes.fhrecorder.view.ColorBarGraph.java

/**
 * Creates the chart with the data from the given data set.
 * //w  ww .j a  v  a 2s.c  o  m
 * @param dataset the data to plot.
 * @return the chart.
 */
private static JFreeChart createChart(final CategoryDataset dataset) {

    final JFreeChart chart = ChartFactory.createStackedBarChart("", "", "", dataset, PlotOrientation.VERTICAL,
            false, true, false);

    StackedBarRenderer renderer = new StackedBarRenderer(true);
    renderer.setShadowVisible(false);
    renderer.setBarPainter(new StandardBarPainter()); // Remove shine
    renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());

    CategoryPlot plot = chart.getCategoryPlot();
    plot.setRenderer(renderer);

    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(new Color(192, 192, 192));

    plot.getDomainAxis().setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    plot.getDomainAxis().setVisible(false);
    plot.getRangeAxis().setVisible(false);
    plot.getDomainAxis().setLowerMargin(.025);
    plot.getDomainAxis().setUpperMargin(.025);

    chart.setBackgroundPaint(new Color(214, 217, 233, 30));

    return chart;
}

From source file:rhinova.gui.dataentry.reserve.ReserveDataEntryPanel.java

private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    // Generated using JFormDesigner non-commercial license
    vSpacer6 = new JPanel(null);
    label1 = new JLabel();
    hSpacer1 = new JPanel(null);
    label2 = new JLabel();
    txtName = new JTextField();
    vSpacer1 = new JPanel(null);
    label3 = new JLabel();
    txtXPos = new JTextField();
    vSpacer2 = new JPanel(null);
    label4 = new JLabel();
    txtYPos = new JTextField();
    hSpacer2 = new JPanel(null);
    vSpacer3 = new JPanel(null);
    label8 = new JLabel();
    txtMin = new JTextField();
    vSpacer4 = new JPanel(null);
    label5 = new JLabel();
    txtMax = new JTextField();
    vSpacer5 = new JPanel(null);
    label6 = new JLabel();
    txtCur = new JTextField();
    vSpacer9 = new JPanel(null);
    label7 = new JLabel();
    txtReg = new JTextField();
    vSpacer7 = new JPanel(null);
    btnCreateReserve = new JButton();
    vSpacer8 = new JPanel(null);

    //======== this ========
    setBorder(new TitledBorder("Reserve"));
    setLayout(new GridBagLayout());
    ((GridBagLayout) getLayout()).columnWidths = new int[] { 0, 65, 145, 0, 0 };
    ((GridBagLayout) getLayout()).rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
            0 };//from   w w  w .  j av  a 2  s  . c o m
    ((GridBagLayout) getLayout()).columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 1.0E-4 };
    ((GridBagLayout) getLayout()).rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
            0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4 };
    add(vSpacer6, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

    //---- label1 ----
    label1.setText("Reserve Entry Panel");
    label1.setFont(new Font("Tahoma", Font.PLAIN, 16));
    add(label1, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 5), 0, 0));
    add(hSpacer1, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

    //---- label2 ----
    label2.setText("name");
    add(label2, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 5), 0, 0));
    add(txtName, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    add(vSpacer1, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

    //---- label3 ----
    label3.setText("x - position");
    add(label3, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 5), 0, 0));
    add(txtXPos, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    add(vSpacer2, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

    //---- label4 ----
    label4.setText("y - position");
    add(label4, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 5), 0, 0));
    add(txtYPos, new GridBagConstraints(2, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    add(hSpacer2, new GridBagConstraints(3, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 0), 0, 0));
    add(vSpacer3, new GridBagConstraints(1, 7, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

    //---- label8 ----
    label8.setText("minimum population");
    add(label8, new GridBagConstraints(1, 8, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 5), 0, 0));
    add(txtMin, new GridBagConstraints(2, 8, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 5, 5), 0, 0));
    add(vSpacer4, new GridBagConstraints(1, 9, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

    //---- label5 ----
    label5.setText("maximum population");
    add(label5, new GridBagConstraints(1, 10, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    add(txtMax, new GridBagConstraints(2, 10, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    add(vSpacer5, new GridBagConstraints(1, 11, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

    //---- label6 ----
    label6.setText("current population");
    add(label6, new GridBagConstraints(1, 12, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    add(txtCur, new GridBagConstraints(2, 12, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    add(vSpacer9, new GridBagConstraints(1, 13, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

    //---- label7 ----
    label7.setText("regeneration rate");
    add(label7, new GridBagConstraints(1, 14, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    add(txtReg, new GridBagConstraints(2, 14, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    add(vSpacer7, new GridBagConstraints(1, 15, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));

    //---- btnCreateReserve ----
    btnCreateReserve.setText("Create Reserve");
    btnCreateReserve.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            btnCreateReserveActionPerformed(e);
        }
    });
    add(btnCreateReserve, new GridBagConstraints(2, 16, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    add(vSpacer8, new GridBagConstraints(2, 17, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0));
    // JFormDesigner - End of component initialization  //GEN-END:initComponents
}

From source file:com.bdb.weather.display.current.WindGauge.java

/**
 * Constructor./*from   w w w .j a  v a  2 s  .c o m*/
 */
public WindGauge() {
    this.setPrefSize(200.0, 200.0);
    lastHeading = 0.0;
    lastSpeed = 0.0;
    plot = new DialPlot();
    for (int i = 0; i < WIND_DIR_ITEMS; i++) {
        datasets[i] = new DefaultValueDataset();
        plot.setDataset(WIND_DIR_DATASET_INDEX_BASE + i, datasets[i]);
    }

    plot.setDataset(WIND_SPEED_DATASET_INDEX, speedDataset);
    plot.setDataset(WIND_GUST_DATASET_INDEX, gustDataset);
    plot.setDataset(MAX_WIND_SPEED_DATASET_INDEX, maxSpeedDataset);
    plot.setDataset(MAX_WIND_GUST_DATASET_INDEX, maxGustDataset);

    plot.addLayer(
            new DialBackground(new GradientPaint(0.0f, 0.0f, Color.LIGHT_GRAY, 100.0f, 0.0f, Color.blue)));

    StandardDialScale scale = new StandardDialScale(0.0, 360.0, 90.0, -360.0, 45.0, 1);
    scale.setTickLabelFont(scale.getTickLabelFont().deriveFont(14.0F).deriveFont(Font.PLAIN));
    scale.setTickRadius(.9);
    scale.setTickLabelFormatter(new CompassHeadingFormat());
    scale.setTickLabelOffset(0.06);
    scale.setMajorTickPaint(new Color(0, 0, 0, 0));
    scale.setTickLabelPaint(Color.BLACK);
    scale.setMinorTickLength(scale.getMajorTickLength());
    scale.setMinorTickStroke(scale.getMajorTickStroke());
    plot.addScale(WIND_DIR_SCALE, scale);

    scale = new StandardDialScale(0.0, 50.0, 225.0, -270.0, 10.0, 9);
    scale.setTickLabelFont(scale.getTickLabelFont().deriveFont(14.0F).deriveFont(Font.PLAIN));
    scale.setTickRadius(.4);
    scale.setTickLabelFormatter(new DecimalFormat("##"));
    scale.setTickLabelOffset(.15);
    scale.setTickLabelPaint(Color.BLACK);
    plot.addScale(WIND_SPEED_SCALE, scale);

    DialPointer.Pointer pointer;
    for (int i = 1; i < WIND_DIR_ITEMS; i++) {
        pointer = new WindDirPointer(.72, .2, WIND_DIR_DATASET_INDEX_BASE + i, false);
        pointer.setOutlinePaint(Color.RED);
        plot.addPointer(pointer);
    }

    plot.setDialFrame(new StandardDialFrame());
    pointer = new WindDirPointer(.72, .2, WIND_DIR_DATASET_INDEX_BASE, true);
    Color fill = Color.CYAN;
    pointer.setFillPaint(fill);
    pointer.setOutlinePaint(Color.BLACK);
    plot.addPointer(pointer);

    DialCap cap = new DialCap();
    plot.setCap(cap);

    DialPointer.Pin speedPin = new DialPointer.Pin(WIND_SPEED_DATASET_INDEX);
    speedPin.setPaint(WIND_SPEED_PIN_COLOR);
    speedPin.setRadius(WIND_SPEED_PIN_RADIUS);
    speedPin.setStroke(new BasicStroke(WIND_SPEED_PIN_WIDTH, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
    plot.addPointer(speedPin);

    DialPointer.Pin gustPin = new DialPointer.Pin(WIND_GUST_DATASET_INDEX);
    gustPin.setPaint(WIND_GUST_PIN_COLOR);
    gustPin.setRadius(WIND_GUST_PIN_RADIUS);
    gustPin.setStroke(new BasicStroke(WIND_SPEED_PIN_WIDTH, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
    plot.addPointer(gustPin);

    DialPointer.Pin maxSpeedPin = new DialPointer.Pin(MAX_WIND_SPEED_DATASET_INDEX);
    maxSpeedPin.setPaint(WIND_SPEED_PIN_COLOR);
    maxSpeedPin.setRadius(MAX_WIND_SPEED_PIN_RADIUS);
    maxSpeedPin
            .setStroke(new BasicStroke(MAX_WIND_SPEED_PIN_WIDTH, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
    plot.addPointer(maxSpeedPin);

    DialPointer.Pin maxGustPin = new DialPointer.Pin(MAX_WIND_GUST_DATASET_INDEX);
    maxGustPin.setPaint(WIND_GUST_PIN_COLOR);
    maxGustPin.setRadius(MAX_WIND_GUST_PIN_RADIUS);
    maxGustPin
            .setStroke(new BasicStroke(MAX_WIND_SPEED_PIN_WIDTH, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
    plot.addPointer(maxGustPin);

    speedAnnotation.setAngle(270.0);
    speedAnnotation.setRadius(.35);
    speedAnnotation.setPaint(Color.cyan);
    plot.addLayer(speedAnnotation);

    double angle = speedAnnotation.getAngle();
    double radius = speedAnnotation.getRadius();

    avgAnnotation.setPaint(Color.cyan);
    avgAnnotation.setAngle(angle);
    avgAnnotation.setRadius(radius + .1);
    plot.addLayer(avgAnnotation);

    for (int i = 0; i < WIND_DIR_ITEMS; i++)
        plot.mapDatasetToScale(WIND_DIR_DATASET_INDEX_BASE + i, WIND_DIR_SCALE);

    plot.mapDatasetToScale(WIND_SPEED_DATASET_INDEX, WIND_SPEED_SCALE);
    plot.mapDatasetToScale(WIND_GUST_DATASET_INDEX, WIND_SPEED_SCALE);
    plot.mapDatasetToScale(MAX_WIND_SPEED_DATASET_INDEX, WIND_SPEED_SCALE);
    plot.mapDatasetToScale(MAX_WIND_GUST_DATASET_INDEX, WIND_SPEED_SCALE);

    StandardDialRange range = new StandardDialRange(0.0, 360.0, Color.BLACK);
    range.setInnerRadius(.70);
    range.setOuterRadius(.72);
    range.setScaleIndex(WIND_DIR_SCALE);
    plot.addLayer(range);

    JFreeChart chart = new JFreeChart(plot);
    chart.setBackgroundPaint(Color.GRAY);

    chartViewer = new ChartViewer(chart);
    //chartViewer.setMinHeight(100);
    //chartViewer.setMinWidth(100);
    //chartViewer.setMaxHeight(400);
    //chartViewer.setMaxWidth(400);
    //chartViewer.setBackground(Color.GRAY);
    //chartViewer.setBorder(new BevelBorder(BevelBorder.RAISED));

    this.setCenter(chartViewer);
    this.setTop(title);
    BorderPane.setAlignment(title, Pos.CENTER);
    title.textProperty().bind(titleProperty);
    setTitle("Wind");

    timeline.setCycleCount(9);
    timeline.setOnFinished((event) -> {
        datasets[0].setValue(currentHeading);
        speedDataset.setValue(currentSpeed);
        lastHeading = currentHeading;
        lastSpeed = currentSpeed;
    });
}

From source file:ToolbarDemo.java

protected void updateMonitor() {
    int index = -1;
    for (int k = 0; k < fontMenus.length; k++) {
        if (fontMenus[k].isSelected()) {
            index = k;/* w w w  .  jav  a 2 s.c o  m*/
            break;
        }
    }
    if (index == -1)
        return;

    if (index == 2) // Courier
    {
        boldMenu.setSelected(false);
        boldMenu.setEnabled(false);
        italicMenu.setSelected(false);
        italicMenu.setEnabled(false);
    } else {
        boldMenu.setEnabled(true);
        italicMenu.setEnabled(true);
    }

    int style = Font.PLAIN;
    if (boldMenu.isSelected())
        style |= Font.BOLD;
    if (italicMenu.isSelected())
        style |= Font.ITALIC;
    Font fn = fonts[index].deriveFont(style);
}

From source file:it.cnr.istc.iloc.gui.TimelinesChart.java

@Override
public void currentNode(Solver.Node n) {
    final CombinedDomainXYPlot combined_plot = new CombinedDomainXYPlot(new DateAxis("Time"));
    combined_plot.setGap(3.0);/* ww w.ja v a2 s  .  c  o m*/
    combined_plot.setOrientation(PlotOrientation.VERTICAL);

    Set<Type> c_types = new HashSet<>();
    LinkedList<Type> queue = new LinkedList<>();
    queue.addAll(solver.getTypes());
    while (!queue.isEmpty()) {
        Type c_type = queue.pollFirst();
        if (!c_types.contains(c_type)) {
            c_types.add(c_type);
            queue.addAll(c_type.getTypes());
        }
    }
    for (Type type : c_types) {
        if (visualizers.containsKey(type.getClass())) {
            for (XYPlot plot : visualizers.get(type.getClass()).getPlots(type)) {
                TextTitle title = new TextTitle(type.name, new Font("SansSerif", Font.PLAIN, 11), Color.BLACK,
                        RectangleEdge.TOP, HorizontalAlignment.CENTER, VerticalAlignment.BOTTOM,
                        new RectangleInsets(4, 4, 4, 4));
                XYTitleAnnotation titleAnn = new XYTitleAnnotation(0.01, 1, title, RectangleAnchor.TOP_LEFT);
                plot.addAnnotation(titleAnn);
                combined_plot.add(plot, 1);
            }
        }
    }
    setChart(new JFreeChart("", new Font("SansSerif", Font.BOLD, 14), combined_plot, false));
    setBorder(BorderFactory.createEtchedBorder());
}

From source file:OrientedTest.java

public BranchGroup createSceneGraph() {

    // Create the root of the branch graph
    BranchGroup objRoot = new BranchGroup();

    TransformGroup objScale = new TransformGroup();
    Transform3D textMat = new Transform3D();
    // Assuming uniform size chars, set scale to fit string in view
    textMat.setScale(1.2 / sl);/*from   ww  w  .  j a v a 2s.co  m*/
    objScale.setTransform(textMat);

    // Create the transform group node and initialize it to the
    // identity. Enable the TRANSFORM_WRITE capability so that
    // our behavior code can modify it at runtime. Add it to the
    // root of the subgraph.
    TransformGroup objTrans = new TransformGroup();
    objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
    objRoot.addChild(objTrans);

    BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0);

    Appearance apText = new Appearance();
    Material m = new Material();
    m.setLightingEnable(true);
    apText.setMaterial(m);

    Appearance apEarth = new Appearance();
    Material mm = new Material();
    mm.setLightingEnable(true);
    apEarth.setMaterial(mm);

    Appearance apStone = new Appearance();
    apStone.setMaterial(mm);

    // create 3D text
    Font3D f3d = new Font3D(new Font(fontName, Font.PLAIN, 2), new FontExtrusion());
    Text3D txt = new Text3D(f3d, textString, new Point3f(-sl / 2.0f, 3.0f, 0.0f));
    OrientedShape3D textShape = new OrientedShape3D();
    textShape.setGeometry(txt);
    textShape.setAppearance(apText);
    textShape.setAlignmentAxis(0.0f, 1.0f, 0.0f);
    objScale.addChild(textShape);

    // Create a simple shape leaf node, add it to the scene graph.

    Transform3D cubeMat = new Transform3D();
    TransformGroup cubeTrans = new TransformGroup(cubeMat);
    cubeMat.set(new Vector3d(0.9, 0.0, -1.0));
    cubeTrans.setTransform(cubeMat);
    cubeTrans.addChild(new ColorCube(0.3));
    objTrans.addChild(cubeTrans);

    TextureLoader stoneTex = new TextureLoader(stoneImage, new String("RGB"), this);
    if (stoneTex != null)
        apStone.setTexture(stoneTex.getTexture());

    TextureAttributes texAttr = new TextureAttributes();
    texAttr.setTextureMode(TextureAttributes.MODULATE);
    apStone.setTextureAttributes(texAttr);

    Transform3D coneMat = new Transform3D();
    TransformGroup coneTrans = new TransformGroup(coneMat);
    coneMat.set(new Vector3d(0.0, 0.0, 0.0));
    coneTrans.setTransform(coneMat);
    coneTrans.addChild(new Cone(.2f, 0.8f, Cone.GENERATE_NORMALS | Cone.GENERATE_TEXTURE_COORDS, apStone));
    objTrans.addChild(coneTrans);

    TextureLoader earthTex = new TextureLoader(earthImage, new String("RGB"), this);
    if (earthTex != null)
        apEarth.setTexture(earthTex.getTexture());

    apEarth.setTextureAttributes(texAttr);

    Transform3D cylinderMat = new Transform3D();
    TransformGroup cylinderTrans = new TransformGroup(cylinderMat);
    cylinderMat.set(new Vector3d(-0.9, 0.5, -1.0));
    cylinderTrans.setTransform(cylinderMat);
    cylinderTrans.addChild(
            new Cylinder(.35f, 2.0f, Cylinder.GENERATE_NORMALS | Cylinder.GENERATE_TEXTURE_COORDS, apEarth));
    objTrans.addChild(cylinderTrans);

    objTrans.addChild(objScale);

    // Set up the background
    Color3f bgColor = new Color3f(0.05f, 0.05f, 0.5f);
    Background bgNode = new Background(bgColor);
    bgNode.setApplicationBounds(bounds);
    objRoot.addChild(bgNode);

    // Set up the ambient light
    Color3f ambientColor = new Color3f(0.1f, 0.1f, 0.1f);
    AmbientLight ambientLightNode = new AmbientLight(ambientColor);
    ambientLightNode.setInfluencingBounds(bounds);
    objRoot.addChild(ambientLightNode);

    // Set up the directional lights
    Color3f light1Color = new Color3f(1.0f, 1.0f, 0.9f);
    Vector3f light1Direction = new Vector3f(1.0f, 1.0f, 1.0f);
    Color3f light2Color = new Color3f(1.0f, 1.0f, 0.9f);
    Vector3f light2Direction = new Vector3f(-1.0f, -1.0f, -1.0f);

    DirectionalLight light1 = new DirectionalLight(light1Color, light1Direction);
    light1.setInfluencingBounds(bounds);
    objRoot.addChild(light1);

    DirectionalLight light2 = new DirectionalLight(light2Color, light2Direction);
    light2.setInfluencingBounds(bounds);
    objRoot.addChild(light2);

    apText.setMaterial(mm);

    // Have Java 3D perform optimizations on this scene graph.
    objRoot.compile();

    return objRoot;
}

From source file:userinterface.graph.AxisSettings.java

public AxisSettings(String name, boolean isDomain, Graph graph) {
    this.name = name;
    this.isDomain = isDomain;
    this.graph = graph;
    this.chart = graph.getChart();
    this.plot = chart.getXYPlot();
    this.axis = (isDomain) ? this.plot.getDomainAxis() : this.plot.getRangeAxis();

    this.valuesFormatter = NumberFormat.getInstance(Locale.UK);

    if (this.valuesFormatter instanceof DecimalFormat)
        ((DecimalFormat) this.valuesFormatter)
                .applyPattern("###,###,###,###,###,###,###,###.########################");

    /* Initialise all the settings. */
    heading = new SingleLineStringSetting("heading", name, "The heading for this axis", this, true);
    headingFont = new FontColorSetting("heading font",
            new FontColorPair(new Font("SansSerif", Font.PLAIN, 12), Color.black),
            "The font for this axis' heading.", this, true);
    numberFont = new FontColorSetting("numbering font",
            new FontColorPair(new Font("SansSerif", Font.PLAIN, 12), Color.black),
            "The font used to number the axis.", this, true);

    showGrid = new BooleanSetting("show gridlines", new Boolean(true), "Should the gridlines be visible", this,
            true);/*from  w w  w .  j  av a2  s . c  o m*/
    gridColour = new ColorSetting("gridline colour", new Color(204, 204, 204), "The colour of the gridlines",
            this, true);

    String[] logarithmicChoices = { "Normal", "Logarithmic" };
    scaleType = new ChoiceSetting("scale type", logarithmicChoices, logarithmicChoices[0],
            "Should the scale be normal, or logarithmic", this, true);
    autoScale = new BooleanSetting("auto-scale", new Boolean(true),
            "When set to true, all minimum values, maximum values, grid intervals, maximum logarithmic powers and minimum logarithmic powers are automatically set and maintained when the data changes.",
            this, true);
    minValue = new DoubleSetting("minimum value", new Double(0.0), "The minimum value for the axis", this,
            true);
    maxValue = new DoubleSetting("maximum value", new Double(1.0), "The maximum value for the axis", this,
            true);
    gridInterval = new DoubleSetting("gridline interval", new Double(0.2), "The interval between gridlines",
            this, false, new RangeConstraint(0, Double.POSITIVE_INFINITY, false, true));
    logBase = new DoubleSetting("log base", new Double(10), "The base for the logarithmic scale", this, false,
            new RangeConstraint("1,"));

    minimumPower = new DoubleSetting("minimum power", new Double("0.0"),
            "The minimum logarithmic power that should be displayed on the scale", this, true);
    maximumPower = new DoubleSetting("maximum power", new Double("1.0"),
            "The maximum logarithmic power that should be displayed on the scale", this, true);

    String[] logStyleChoices = { "Values", "Base and exponent" };
    logStyle = new ChoiceSetting("logarithmic number style", logStyleChoices, logStyleChoices[1],
            "Should the style of the logarithmic scale show the actual values, or the base with the exponent.",
            this, false);

    /* Add constraints. */
    minValue.addConstraint(new NumericConstraint() {
        public void checkValueDouble(double d) throws SettingException {
            if (activated && d >= maxValue.getDoubleValue())
                throw new SettingException("Minimum value should be < Maximum value");
        }

        public void checkValueInteger(int i) throws SettingException {
            if (activated && i >= maxValue.getDoubleValue())
                throw new SettingException("Minimum value should be < Maximum value");
        }

        public void checkValueLong(long i) throws SettingException {
            if (activated && i >= maxValue.getDoubleValue())
                throw new SettingException("Minimum value should be < Maximum value");
        }
    });
    maxValue.addConstraint(new NumericConstraint() {
        public void checkValueDouble(double d) throws SettingException {
            if (activated && d <= minValue.getDoubleValue())
                throw new SettingException("Maximum value should be > Minimum value");
        }

        public void checkValueInteger(int i) throws SettingException {
            if (activated && i <= minValue.getDoubleValue())
                throw new SettingException("Maximum value should be > Minimum value");
        }

        public void checkValueLong(long i) throws SettingException {
            if (activated && i <= maxValue.getDoubleValue())
                throw new SettingException("Minimum value should be > Maximum value");
        }
    });
    minimumPower.addConstraint(new NumericConstraint() {
        public void checkValueDouble(double d) throws SettingException {
            if (activated && d >= maximumPower.getDoubleValue())
                throw new SettingException("Minimum power should be < Maximum power");
        }

        public void checkValueInteger(int i) throws SettingException {
            if (activated && i >= maximumPower.getDoubleValue())
                throw new SettingException("Minimum power should be < Maximum power");
        }

        public void checkValueLong(long i) throws SettingException {
            if (activated && i >= maximumPower.getDoubleValue())
                throw new SettingException("Minimum power should be < Maximum power");
        }
    });
    maximumPower.addConstraint(new NumericConstraint() {
        public void checkValueDouble(double d) throws SettingException {
            if (activated && d <= minimumPower.getDoubleValue())
                throw new SettingException("Maximum power should be > Minimum power");
        }

        public void checkValueInteger(int i) throws SettingException {
            if (activated && i <= minimumPower.getDoubleValue())
                throw new SettingException("Maximum power should be > Minimum power");
        }

        public void checkValueLong(long i) throws SettingException {
            if (activated && i <= minimumPower.getDoubleValue())
                throw new SettingException("Maximum power should be > Minimum power");
        }
    });

    doEnables();
    display = null;
    activated = true;

    updateAxis();
    setChanged();
    notifyObservers();
}

From source file:org.pau.assetmanager.viewmodel.chart.PrepareChart.java

public static void preparePropertiesVsOwnAllPropertiesJFreeChart(JFreeChart jfchart,
        CategoryDataset categoryModel) {

    CategoryPlot categoryPlot = ((CategoryPlot) jfchart.getPlot());
    categoryPlot.getRangeAxis().resizeRange(1.2);
    categoryPlot.setBackgroundPaint(Color.WHITE);
    categoryPlot.setDomainGridlinePaint(Color.WHITE);
    categoryPlot.setRangeMinorGridlinePaint(Color.WHITE);
    categoryPlot.setRangeGridlinePaint(Color.BLACK);
    BarRenderer renderer = (BarRenderer) categoryPlot.getRenderer();

    renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    renderer.setBaseItemLabelsVisible(true);

    renderer.setBaseItemLabelFont(new Font("Serif", Font.PLAIN, 10));
    renderer.setItemLabelAnchorOffset(15);

    renderer.setSeriesStroke(0, new BasicStroke(1));
    renderer.setSeriesStroke(1, new BasicStroke(1));
    renderer.setSeriesStroke(2, new BasicStroke(1));
    renderer.setSeriesStroke(3, new BasicStroke(1));
    renderer.setSeriesStroke(4, new BasicStroke(1));
    renderer.setSeriesStroke(5, new BasicStroke(1));
    renderer.setSeriesPaint(0, new Color(0x77, 0x77, 0xFF));
    renderer.setSeriesPaint(1, new Color(0xCC, 0xCC, 0xFF));
    renderer.setSeriesPaint(2, new Color(0x00, 0x00, 0xFF));
    renderer.setSeriesPaint(3, new Color(0xFF, 0x77, 0x77));
    renderer.setSeriesPaint(4, new Color(0xFF, 0xCC, 0xCC));
    renderer.setSeriesPaint(5, new Color(0xFF, 0x00, 0x00));
    for (int i = 0; i < categoryModel.getColumnKeys().size(); i++) {
        String label = (String) categoryModel.getColumnKey(i);
        CategoryMarker marker = new CategoryMarker(label);
        marker.setLabel("");
        marker.setPaint(Color.cyan);
        marker.setOutlinePaint(Color.cyan);
        marker.setAlpha(0.1f);/*w  w w  . j av  a2  s.c o m*/
        marker.setLabelAnchor(RectangleAnchor.TOP);
        marker.setLabelTextAnchor(TextAnchor.TOP_CENTER);
        marker.setLabelOffsetType(LengthAdjustmentType.CONTRACT);
        categoryPlot.addDomainMarker(marker, Layer.BACKGROUND);
    }
    renderer.setDrawBarOutline(false);
    renderer.setShadowVisible(false);
    renderer.setItemMargin(.1);
    renderer.setBarPainter(new StandardBarPainter());
    renderer.setBasePositiveItemLabelPosition(
            new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.TOP_RIGHT));
    renderer.setBaseNegativeItemLabelPosition(
            new ItemLabelPosition(ItemLabelAnchor.OUTSIDE6, TextAnchor.BOTTOM_RIGHT));
}