java.awt.Color#blue ( )源码实例Demo

下面列出了java.awt.Color#blue ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: buffer_bci   文件: ColorBlockTest.java
/**
 * Confirm that the equals() method can distinguish all the required fields.
 */
@Test
public void testEquals() {
    ColorBlock b1 = new ColorBlock(Color.red, 1.0, 2.0);
    ColorBlock b2 = new ColorBlock(Color.red, 1.0, 2.0);
    assertTrue(b1.equals(b2));
    assertTrue(b2.equals(b2));

    b1 = new ColorBlock(Color.blue, 1.0, 2.0);
    assertFalse(b1.equals(b2));
    b2 = new ColorBlock(Color.blue, 1.0, 2.0);
    assertTrue(b1.equals(b2));

    b1 = new ColorBlock(Color.blue, 1.1, 2.0);
    assertFalse(b1.equals(b2));
    b2 = new ColorBlock(Color.blue, 1.1, 2.0);
    assertTrue(b1.equals(b2));

    b1 = new ColorBlock(Color.blue, 1.1, 2.2);
    assertFalse(b1.equals(b2));
    b2 = new ColorBlock(Color.blue, 1.1, 2.2);
    assertTrue(b1.equals(b2));
}
 
源代码2 项目: SIMVA-SoS   文件: BlockBorderTest.java
/**
 * Confirm that the equals() method can distinguish all the required fields.
 */
@Test
public void testEquals() {
    BlockBorder b1 = new BlockBorder(new RectangleInsets(1.0, 2.0, 3.0,
            4.0), Color.red);
    BlockBorder b2 = new BlockBorder(new RectangleInsets(1.0, 2.0, 3.0,
            4.0), Color.red);
    assertTrue(b1.equals(b2));
    assertTrue(b2.equals(b2));

    // insets
    b1 = new BlockBorder(new RectangleInsets(UnitType.RELATIVE, 1.0, 2.0,
            3.0, 4.0), Color.red);
    assertFalse(b1.equals(b2));
    b2 = new BlockBorder(new RectangleInsets(UnitType.RELATIVE, 1.0, 2.0,
            3.0, 4.0), Color.red);
    assertTrue(b1.equals(b2));

    // paint
    b1 = new BlockBorder(new RectangleInsets(1.0, 2.0, 3.0, 4.0),
            Color.blue);
    assertFalse(b1.equals(b2));
    b2 = new BlockBorder(new RectangleInsets(1.0, 2.0, 3.0, 4.0),
            Color.blue);
    assertTrue(b1.equals(b2));
}
 
源代码3 项目: ccu-historian   文件: ColorBlockTest.java
/**
 * Confirm that cloning works.
 */
@Test
public void testCloning() {
    GradientPaint gp = new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f,
            Color.blue);
    Rectangle2D bounds1 = new Rectangle2D.Double(10.0, 20.0, 30.0, 40.0);
    ColorBlock b1 = new ColorBlock(gp, 1.0, 2.0);
    b1.setBounds(bounds1);
    ColorBlock b2 = null;

    try {
        b2 = (ColorBlock) b1.clone();
    }
    catch (CloneNotSupportedException e) {
        fail(e.toString());
    }
    assertTrue(b1 != b2);
    assertTrue(b1.getClass() == b2.getClass());
    assertTrue(b1.equals(b2));

    // check independence
    bounds1.setRect(1.0, 2.0, 3.0, 4.0);
    assertFalse(b1.equals(b2));
    b2.setBounds(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
    assertTrue(b1.equals(b2));
}
 
源代码4 项目: hottub   文件: MlibOpsTest.java
private static BufferedImage createSrcImage() {
    BufferedImage img = createImage();

    Graphics2D g = img.createGraphics();
    Color[] colors = { Color.red, Color.green, Color.blue };
    float[] dist = {0.0f, 0.5f, 1.0f };
    Point2D center = new Point2D.Float(0.5f * w, 0.5f * h);

    RadialGradientPaint p =
            new RadialGradientPaint(center, 0.5f * w, dist, colors);
    g.setPaint(p);
    g.fillRect(0, 0, w, h);
    g.dispose();

    return img;
}
 
源代码5 项目: dragonwell8_jdk   文件: ConcurrentWritingTest.java
private static BufferedImage createTestImage() {
    int w = 1024;
    int h = 768;

    BufferedImage img = new
        BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
    Graphics2D g = img.createGraphics();
    Color[] colors = { Color.red, Color.green, Color.blue };
    float[] dist = {0.0f, 0.5f, 1.0f };
    Point2D center = new Point2D.Float(0.5f * w, 0.5f * h);

    RadialGradientPaint p =
        new RadialGradientPaint(center, 0.5f * w, dist, colors);
    g.setPaint(p);
    g.fillRect(0, 0, w, h);
    g.dispose();

    return img;
}
 
源代码6 项目: openstock   文件: LegendItemCollectionTest.java
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
@Test
public void testEquals() {

    LegendItemCollection c1 = new LegendItemCollection();
    LegendItemCollection c2 = new LegendItemCollection();
    assertEquals(c1, c2);
    assertEquals(c2, c1);

    LegendItem item1 = new LegendItem("Label", "Description",
            "ToolTip", "URL", true,
            new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), true, Color.red,
            true, Color.blue, new BasicStroke(1.2f), true,
            new Line2D.Double(1.0, 2.0, 3.0, 4.0),
            new BasicStroke(2.1f), Color.green);
    LegendItem item2 = new LegendItem("Label", "Description",
            "ToolTip", "URL", true,
            new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0),
            true, Color.red, true, Color.blue, new BasicStroke(1.2f), true,
            new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f),
            Color.green);
    c1.add(item1);
    assertFalse(c1.equals(c2));
    c2.add(item2);
    assertEquals(c1, c2);

}
 
源代码7 项目: SIMVA-SoS   文件: XYDifferenceRendererTest.java
/**
 * Serialize an instance, restore it, and check for equality.
 */
@Test
public void testSerialization() {
    XYDifferenceRenderer r1 = new XYDifferenceRenderer(Color.red,
            Color.blue, false);
    XYDifferenceRenderer r2 = (XYDifferenceRenderer) 
            TestUtilities.serialised(r1);
    assertEquals(r1, r2);
}
 
源代码8 项目: openjdk-8   文件: XTable.java
/**
 * This method sets read write rows to be blue, and other rows to be their
 * default rendered colour.
 */
@Override
public TableCellRenderer getCellRenderer(int row, int column) {
    DefaultTableCellRenderer tcr =
        (DefaultTableCellRenderer) super.getCellRenderer(row,column);
    tcr.setToolTipText(getToolTip(row,column));
    if (defaultColor == null) {
        defaultColor = tcr.getForeground();
        editableColor = Color.blue;
        errorColor = Color.red;
        // this sometimes happens for some reason
        if (defaultColor == null) {
            return tcr;
        }
    }
    if (column != VALUE_COLUMN) {
        tcr.setForeground(defaultColor);
        return tcr;
    }
    if (isCellError(row,column)) {
        tcr.setForeground(errorColor);
    } else if (isCellEditable(row, column)) {
        tcr.setForeground(editableColor);
    } else {
        tcr.setForeground(defaultColor);
    }
    return tcr;
}
 
源代码9 项目: jdk8u60   文件: XTable.java
/**
 * This method sets read write rows to be blue, and other rows to be their
 * default rendered colour.
 */
@Override
public TableCellRenderer getCellRenderer(int row, int column) {
    DefaultTableCellRenderer tcr =
        (DefaultTableCellRenderer) super.getCellRenderer(row,column);
    tcr.setToolTipText(getToolTip(row,column));
    if (defaultColor == null) {
        defaultColor = tcr.getForeground();
        editableColor = Color.blue;
        errorColor = Color.red;
        // this sometimes happens for some reason
        if (defaultColor == null) {
            return tcr;
        }
    }
    if (column != VALUE_COLUMN) {
        tcr.setForeground(defaultColor);
        return tcr;
    }
    if (isCellError(row,column)) {
        tcr.setForeground(errorColor);
    } else if (isCellEditable(row, column)) {
        tcr.setForeground(editableColor);
    } else {
        tcr.setForeground(defaultColor);
    }
    return tcr;
}
 
源代码10 项目: jdk8u-dev-jdk   文件: ConcurrentReadingTest.java
private static void createTestFile() {
    int w = 1280;
    int h = 1024;

    BufferedImage img = new
        BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
    Graphics2D g = img.createGraphics();
    Color[] colors = { Color.red, Color.green, Color.blue };
    float[] dist = {0.0f, 0.5f, 1.0f };
    Point2D center = new Point2D.Float(0.5f * w, 0.5f * h);

    RadialGradientPaint p =
        new RadialGradientPaint(center, 0.5f * w, dist, colors);
    g.setPaint(p);
    g.fillRect(0, 0, w, h);
    g.dispose();

    try {
        System.out.println("Create test image " + file.getAbsolutePath());
        boolean b = ImageIO.write(img, "JPEG", file);
        if (!b) {
            throw new RuntimeException("Failed to create test image.");
        }
    } catch (IOException e) {
        throw new RuntimeException("Test failed", e);
    }
}
 
源代码11 项目: SIMVA-SoS   文件: XYShapeAnnotationTest.java
/**
 * Confirm that cloning works.
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    XYShapeAnnotation a1 = new XYShapeAnnotation(
            new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0),
            new BasicStroke(1.2f), Color.red, Color.blue);
    XYShapeAnnotation a2 = (XYShapeAnnotation) a1.clone();
    assertTrue(a1 != a2);
    assertTrue(a1.getClass() == a2.getClass());
    assertTrue(a1.equals(a2));
}
 
源代码12 项目: SIMVA-SoS   文件: DefaultTitleEditor.java
/**
 * Allow the user the opportunity to select a Paint object.  For now, we
 * just use the standard color chooser - all colors are Paint objects, but
 * not all Paint objects are colors (later we can implement a more general
 * Paint chooser).
 */
public void attemptPaintSelection() {
    Paint p = this.titlePaint.getPaint();
    Color defaultColor = (p instanceof Color ? (Color) p : Color.blue);
    Color c = JColorChooser.showDialog(
        this, localizationResources.getString("Title_Color"), defaultColor
    );
    if (c != null) {
        this.titlePaint.setPaint(c);
    }
}
 
源代码13 项目: MeteoInfo   文件: MeteoInfoScript.java
private Color getColor(String style) {
    if (style.contains("r")) {
        return Color.red;
    } else if (style.contains("k")) {
        return Color.black;
    } else if (style.contains("b")) {
        return Color.blue;
    } else if (style.contains("g")) {
        return Color.green;
    } else if (style.contains("w")) {
        return Color.white;
    } else {
        return null;
    }
}
 
源代码14 项目: openstock   文件: XYShapeAnnotationTest.java
/**
 * Checks that this class implements PublicCloneable.
 */
@Test
public void testPublicCloneable() {
    XYShapeAnnotation a1 = new XYShapeAnnotation(
            new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0),
            new BasicStroke(1.2f), Color.red, Color.blue);
    assertTrue(a1 instanceof PublicCloneable);
}
 
源代码15 项目: openjdk-8   文件: ReadingInterruptionTest.java
private static void createTestFile() {
    int w = 1280;
    int h = 1024;

    BufferedImage img = new
        BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
    Graphics2D g = img.createGraphics();
    Color[] colors = { Color.red, Color.green, Color.blue };
    float[] dist = {0.0f, 0.5f, 1.0f };
    Point2D center = new Point2D.Float(0.5f * w, 0.5f * h);

    RadialGradientPaint p =
        new RadialGradientPaint(center, 0.5f * w, dist, colors);
    g.setPaint(p);
    g.fillRect(0, 0, w, h);
    g.dispose();

    try {
        System.out.println("Create test image " + file.getAbsolutePath());
        boolean b = ImageIO.write(img, "JPEG", file);
        if (!b) {
            throw new RuntimeException("Failed to create test image.");
        }
    } catch (IOException e) {
        throw new RuntimeException("Test failed", e);
    }
}
 
源代码16 项目: openjdk-jdk8u-backup   文件: XTable.java
/**
 * This method sets read write rows to be blue, and other rows to be their
 * default rendered colour.
 */
@Override
public TableCellRenderer getCellRenderer(int row, int column) {
    DefaultTableCellRenderer tcr =
        (DefaultTableCellRenderer) super.getCellRenderer(row,column);
    tcr.setToolTipText(getToolTip(row,column));
    if (defaultColor == null) {
        defaultColor = tcr.getForeground();
        editableColor = Color.blue;
        errorColor = Color.red;
        // this sometimes happens for some reason
        if (defaultColor == null) {
            return tcr;
        }
    }
    if (column != VALUE_COLUMN) {
        tcr.setForeground(defaultColor);
        return tcr;
    }
    if (isCellError(row,column)) {
        tcr.setForeground(errorColor);
    } else if (isCellEditable(row, column)) {
        tcr.setForeground(editableColor);
    } else {
        tcr.setForeground(defaultColor);
    }
    return tcr;
}
 
源代码17 项目: buffer_bci   文件: XYDifferenceRendererTest.java
/**
 * Two objects that are equal are required to return the same hashCode.
 */
@Test
public void testHashcode() {
    XYDifferenceRenderer r1
        = new XYDifferenceRenderer(Color.red, Color.blue, false);
    XYDifferenceRenderer r2
        = new XYDifferenceRenderer(Color.red, Color.blue, false);
    assertTrue(r1.equals(r2));
    int h1 = r1.hashCode();
    int h2 = r2.hashCode();
    assertEquals(h1, h2);
}
 
源代码18 项目: ECG-Viewer   文件: XYShapeAnnotationTest.java
/**
 * Checks that this class implements PublicCloneable.
 */
@Test
public void testPublicCloneable() {
    XYShapeAnnotation a1 = new XYShapeAnnotation(
            new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0),
            new BasicStroke(1.2f), Color.red, Color.blue);
    assertTrue(a1 instanceof PublicCloneable);
}
 
源代码19 项目: astor   文件: ChartPanel.java
/**
 * Constructs a JFreeChart panel.
 *
 * @param chart  the chart.
 * @param width  the preferred width of the panel.
 * @param height  the preferred height of the panel.
 * @param minimumDrawWidth  the minimum drawing width.
 * @param minimumDrawHeight  the minimum drawing height.
 * @param maximumDrawWidth  the maximum drawing width.
 * @param maximumDrawHeight  the maximum drawing height.
 * @param useBuffer  a flag that indicates whether to use the off-screen
 *                   buffer to improve performance (at the expense of
 *                   memory).
 * @param properties  a flag indicating whether or not the chart property
 *                    editor should be available via the popup menu.
 * @param copy  a flag indicating whether or not a copy option should be
 *              available via the popup menu.
 * @param save  a flag indicating whether or not save options should be
 *              available via the popup menu.
 * @param print  a flag indicating whether or not the print option
 *               should be available via the popup menu.
 * @param zoom  a flag indicating whether or not zoom options should be
 *              added to the popup menu.
 * @param tooltips  a flag indicating whether or not tooltips should be
 *                  enabled for the chart.
 *
 * @since 1.0.13
 */
public ChartPanel(JFreeChart chart, int width, int height,
       int minimumDrawWidth, int minimumDrawHeight, int maximumDrawWidth,
       int maximumDrawHeight, boolean useBuffer, boolean properties,
       boolean copy, boolean save, boolean print, boolean zoom,
       boolean tooltips) {

    setChart(chart);
    this.chartMouseListeners = new EventListenerList();
    this.info = new ChartRenderingInfo();
    this.info.setRenderingSource(this);
    setPreferredSize(new Dimension(width, height));
    this.useBuffer = useBuffer;
    this.refreshBuffer = false;
    this.minimumDrawWidth = minimumDrawWidth;
    this.minimumDrawHeight = minimumDrawHeight;
    this.maximumDrawWidth = maximumDrawWidth;
    this.maximumDrawHeight = maximumDrawHeight;
    this.zoomTriggerDistance = DEFAULT_ZOOM_TRIGGER_DISTANCE;

    // set up popup menu...
    this.popup = null;
    if (properties || copy || save || print || zoom) {
        this.popup = createPopupMenu(properties, copy, save, print, zoom);
    }

    enableEvents(AWTEvent.MOUSE_EVENT_MASK);
    enableEvents(AWTEvent.MOUSE_MOTION_EVENT_MASK);
    setDisplayToolTips(tooltips);
    addMouseListener(this);
    addMouseMotionListener(this);

    this.defaultDirectoryForSaveAs = null;
    this.enforceFileExtensions = true;

    // initialize ChartPanel-specific tool tip delays with
    // values the from ToolTipManager.sharedInstance()
    ToolTipManager ttm = ToolTipManager.sharedInstance();
    this.ownToolTipInitialDelay = ttm.getInitialDelay();
    this.ownToolTipDismissDelay = ttm.getDismissDelay();
    this.ownToolTipReshowDelay = ttm.getReshowDelay();

    this.zoomAroundAnchor = false;
    this.zoomOutlinePaint = Color.blue;
    this.zoomFillPaint = new Color(0, 0, 255, 63);

    this.overlays = new java.util.ArrayList();

    this.availableMouseHandlers = new java.util.ArrayList();

    this.zoomHandler = new ZoomHandler();
    this.availableMouseHandlers.add(zoomHandler);

    PanHandler panHandler = new PanHandler();
    int panMask = InputEvent.CTRL_MASK;
    // for MacOSX we can't use the CTRL key for mouse drags, see:
    // http://developer.apple.com/qa/qa2004/qa1362.html
    String osName = System.getProperty("os.name").toLowerCase();
    if (osName.startsWith("mac os x")) {
        panMask = InputEvent.ALT_MASK;
    }
    panHandler.setModifier(panMask);
    this.availableMouseHandlers.add(panHandler);
    this.auxiliaryMouseHandlers = new java.util.ArrayList();
}
 
源代码20 项目: buffer_bci   文件: PeriodAxisLabelInfoTest.java
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
@Test
public void testEquals() {
    PeriodAxisLabelInfo info1 = new PeriodAxisLabelInfo(Day.class,
            new SimpleDateFormat("d"));
    PeriodAxisLabelInfo info2 = new PeriodAxisLabelInfo(Day.class,
            new SimpleDateFormat("d"));
    assertTrue(info1.equals(info2));
    assertTrue(info2.equals(info1));

    Class c1 = Day.class;
    Class c2 = Month.class;
    DateFormat df1 = new SimpleDateFormat("d");
    DateFormat df2 = new SimpleDateFormat("MMM");
    RectangleInsets sp1 = new RectangleInsets(1, 1, 1, 1);
    RectangleInsets sp2 = new RectangleInsets(2, 2, 2, 2);
    Font lf1 = new Font("SansSerif", Font.PLAIN, 10);
    Font lf2 = new Font("SansSerif", Font.BOLD, 9);
    Paint lp1 = Color.black;
    Paint lp2 = Color.blue;
    boolean b1 = true;
    boolean b2 = false;
    Stroke s1 = new BasicStroke(0.5f);
    Stroke s2 = new BasicStroke(0.25f);
    Paint dp1 = Color.red;
    Paint dp2 = Color.green;

    info1 = new PeriodAxisLabelInfo(c2, df1, sp1, lf1, lp1, b1, s1, dp1);
    info2 = new PeriodAxisLabelInfo(c1, df1, sp1, lf1, lp1, b1, s1, dp1);
    assertFalse(info1.equals(info2));
    info2 = new PeriodAxisLabelInfo(c2, df1, sp1, lf1, lp1, b1, s1, dp1);
    assertTrue(info1.equals(info2));

    info1 = new PeriodAxisLabelInfo(c2, df2, sp1, lf1, lp1, b1, s1, dp1);
    assertFalse(info1.equals(info2));
    info2 = new PeriodAxisLabelInfo(c2, df2, sp1, lf1, lp1, b1, s1, dp1);
    assertTrue(info1.equals(info2));

    info1 = new PeriodAxisLabelInfo(c2, df2, sp2, lf1, lp1, b1, s1, dp1);
    assertFalse(info1.equals(info2));
    info2 = new PeriodAxisLabelInfo(c2, df2, sp2, lf1, lp1, b1, s1, dp1);
    assertTrue(info1.equals(info2));

    info1 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp1, b1, s1, dp1);
    assertFalse(info1.equals(info2));
    info2 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp1, b1, s1, dp1);
    assertTrue(info1.equals(info2));

    info1 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b1, s1, dp1);
    assertFalse(info1.equals(info2));
    info2 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b1, s1, dp1);
    assertTrue(info1.equals(info2));

    info1 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b2, s1, dp1);
    assertFalse(info1.equals(info2));
    info2 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b2, s1, dp1);
    assertTrue(info1.equals(info2));

    info1 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b2, s2, dp1);
    assertFalse(info1.equals(info2));
    info2 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b2, s2, dp1);
    assertTrue(info1.equals(info2));

    info1 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b2, s2, dp2);
    assertFalse(info1.equals(info2));
    info2 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b2, s2, dp2);
    assertTrue(info1.equals(info2));

}