Java 8 BasicStroke - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 BasicStroke class.

This code example shows how to use the following methods:getDashArray, getDashPhase, getEndCap, getLineJoin, getLineWidth
This code example shows how to use the following methods:
 
      g2d.setColor(getBackground());
      g2d.fill(flagShape);
       
      // draw outline 
      Stroke pen = new BasicStroke(1.0F);
      g2d.setStroke(pen);
      //g2d.setColor(new Color(0.6f,0.6f,0.6f)); 
      g2d.setColor(Color.white);
      g2d.draw(flagShape);      
 
      g2d.setColor(getForeground());
      g2d.drawString(text, textBox.x + PADDING_X, 
            textBox.y +  textBox.height - fm.getDescent() - PADDING_Y);
 
   } 
 
 
} 
6
CodeRank
This code example shows how to use the following methods:getDashArray, getDashPhase, getEndCap, getLineJoin, getLineWidth
   */ 
  public void writeObject (final Object o, final ObjectOutputStream stream)
          throws IOException
  { 
    final BasicStroke s = (BasicStroke) o;
    stream.writeFloat(s.getLineWidth());
    stream.writeInt(s.getEndCap());
    stream.writeInt(s.getLineJoin());
    stream.writeFloat(s.getMiterLimit());
    stream.writeObject(s.getDashArray());
    stream.writeFloat(s.getDashPhase());
  } 
 
  /** 
   * Reads the object from the object input stream. 
   * 
   * @param stream the object input stream from where to read the serialized data. 
   * @return the generated object. 
   * 
   * @throws IOException            if reading the stream failed. 
7
CodeRank
This code example shows how to use the following methods:
   } 
 
   public void paintComponent(Graphics g){
      super.paintComponent(g);
      Graphics2D g2d = (Graphics2D)g;
      Stroke pen = new BasicStroke(3.0F);    
      g2d.setStroke(pen);
      g2d.drawRect(0,0,getActualWidth()-1,getActualHeight()-1);
 
   }  
 
} 
6
CodeRank
This code example shows how to use the following methods:
     * Confirm that the equals method can distinguish all the required fields. 
     */ 
    @Test
    public void testEquals() { 
 
        BasicStroke s1 = new BasicStroke(1.0f);
        BasicStroke s2 = new BasicStroke(2.0f);
        CategoryLineAnnotation a1 = new CategoryLineAnnotation("Category 1",
                1.0, "Category 2", 2.0, Color.RED, s1);
        CategoryLineAnnotation a2 = new CategoryLineAnnotation("Category 1",
                1.0, "Category 2", 2.0, Color.RED, s1);
        assertEquals(a1, a2);
        assertEquals(a2, a1);
 
        // category 1 
        a1.setCategory1("Category A");
        assertFalse(a1.equals(a2));
        a2.setCategory1("Category A");
        assertEquals(a1, a2);
 
6
CodeRank
This code example shows how to use the following methods:equals, hashCode
 
    /** 
     * Two objects that are equal are required to return the same hashCode.  
     */ 
    public void testColorHashcode() { 
        final Stroke s1 = new BasicStroke(1.5f);
        final Stroke s2 = new BasicStroke(1.5f);
        assertTrue(s1.equals(s2));
        final int h1 = s1.hashCode();
        final int h2 = s2.hashCode();
        assertEquals(h1, h2);
    } 
 
} 
6
CodeRank
This code example shows how to use the following methods:getDashArray, getDashPhase, getEndCap, getLineJoin, getLineWidth
This code example shows how to use the following methods:
       
   @Override 
   public void paintComponent(Graphics g){
      super.paintComponent(g);
      Graphics2D g2d = (Graphics2D)g;
      Stroke pen = new BasicStroke(3.0F);    
      g2d.setStroke(pen);
       
      g2d.drawRect(0,0,_model.getWidth()-1,_model.getHeight()-1);
   }  
    
} 
6
CodeRank
This code example shows how to use the following methods:
This code example shows how to use the following methods:
    /** 
     * A test for bug report 1808376. 
     */ 
    @Test
    public void test1808376() { 
        Stroke stroke = new BasicStroke(1.0f);
        Stroke outlineStroke = new BasicStroke(2.0f);
        ValueMarker m = new ValueMarker(1.0, Color.RED, stroke, Color.BLUE,
                outlineStroke, 0.5f);
        assertEquals(1.0, m.getValue(), EPSILON);
        assertEquals(Color.RED, m.getPaint());
        assertEquals(stroke, m.getStroke());
        assertEquals(Color.BLUE, m.getOutlinePaint());
        assertEquals(outlineStroke, m.getOutlineStroke());
        assertEquals(0.5f, m.getAlpha(), EPSILON);
    } 
 
} 
6
CodeRank
See Code Examples for Java 8 BasicStroke Methods: