Draw String and Star : Geometry « Advanced Graphics « Java

Java
1. 2D Graphics GUI
2. 3D
3. Advanced Graphics
4. Ant
5. Apache Common
6. Chart
7. Collections Data Structure
8. Database SQL JDBC
9. Design Pattern
10. Development Class
11. Email
12. Event
13. File Input Output
14. Game
15. Hibernate
16. J2EE
17. J2ME
18. JDK 6
19. JSP
20. JSTL
21. Language Basics
22. Network Protocol
23. PDF RTF
24. Regular Expressions
25. Security
26. Servlets
27. Spring
28. Swing Components
29. Swing JFC
30. SWT JFace Eclipse
31. Threads
32. Tiny Application
33. Velocity
34. Web Services SOA
35. XML
Microsoft Office Word 2007 Tutorial
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Java » Advanced Graphics » GeometryScreenshots 
Draw String and Star
Draw String and Star

import java.awt.*;

import javax.swing.*;

import no.geosoft.cc.geometry.Geometry;
import no.geosoft.cc.graphics.*;



/**
 * G demo program. Demonstrates:
 *
 * <ul>
 *   <li> Basic graphic window and scene setup
 *   <li> Setting canvas background color
 *   <li> Basic scene composition
 *   <li> The use of style
 *   <li> Example geometry generation
 *   <li> Simple annotation with positioning
 * </ul>
 
 @author <a href="mailto:jacob.dreyer@geosoft.no">Jacob Dreyer</a>
 */   
public class Demo1 extends JFrame
{
  public Demo1()
  {
    super ("G Graphics Library - Demo 1");    
    setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
    
    // Create the graphic canvas
    GWindow window = new GWindow(new Color (210235255));
    getContentPane().add (window.getCanvas());
    
    // Create scene with default viewport and world extent settings
    GScene scene = new GScene (window);

    // Create the graphics object and add to the scene
    GObject helloWorld = new HelloWorld();
    scene.add (helloWorld);

    pack();
    setSize (new Dimension (500500));
    setVisible (true);
  }


  
  /**
   * Defines the geometry and presentation for the sample
   * graphic object.
   */   
  public class HelloWorld extends GObject
  {
    private GSegment star_;
    
    
    public HelloWorld()
    {
      star_ = new GSegment();
      GStyle starStyle = new GStyle();
      starStyle.setForegroundColor (new Color (25500));
      starStyle.setBackgroundColor (new Color (2552550));
      starStyle.setLineWidth (3);
      setStyle (starStyle);
      addSegment (star_);
      
      GText text = new GText ("HelloWorld", GPosition.MIDDLE);
      GStyle textStyle = new GStyle();
      textStyle.setForegroundColor (new Color (100100150));
      textStyle.setBackgroundColor (null);
      textStyle.setFont (new Font ("Dialog", Font.BOLD, 48));
      text.setStyle (textStyle);
      star_.setText (text);
    }
    

  
    /**
     * This method is called whenever the canvas needs to redraw this
     * object. For efficiency, prepare as much of the graphic object
     * up front (such as sub object, segment and style setup) and
     * set geometry only in this method.
     */
    public void draw()
    {
      star_.setGeometry (Geometry.createStar (2202202008015));
    }
  }
  


  public static void main (String[] args)
  {
    new Demo1();
  }
}

           
       
G-DrawStringAndStar.zip( 190 k)
Related examples in the same category
1. Update World Extent GeometryUpdate World Extent Geometry
2. Gemometry GenerationGemometry Generation
3. Embedded AWT components, Custom selection interaction, Dynamic annotationsEmbedded AWT components, Custom selection interaction, Dynamic annotations
4. Advaced geometry generation
5. Draw Radiation: Annotation layout mechanism, Visibility settings, Custom linestyleDraw Radiation: Annotation layout mechanism, Visibility settings, Custom linestyle
ww___w_.__jav__a___2_s___.c__o__m__ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.