Draw Radiation: Annotation layout mechanism, Visibility settings, Custom linestyle : 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 Radiation: Annotation layout mechanism, Visibility settings, Custom linestyle
Draw Radiation: Annotation layout mechanism, Visibility settings, Custom linestyle

import java.awt.*;
import java.awt.event.*;

import javax.swing.*;

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



/**
 * G demo program. Demonstrates:
 *
 * <ul>
 * <li>Annotation layout mechanism
 * <li>Visibility settings
 * <li>Custom linestyle
 * </ul>
 
 @author <a href="mailto:jacob.dreyer@geosoft.no">Jacob Dreyer</a>
 */   
public class Demo3 extends JFrame
  implements ActionListener
{
  private JCheckBox  annotationToggle_;
  private JCheckBox  geometryToggle_;

  private GScene     scene_;
  
  

  /**
   * Class for creating the demo canvas and hande Swing events.
   */   
  public Demo3()
  {
    super ("G Graphics Library - Demo 3");
    setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
    
    // Create the GUI
    JPanel topLevel = new JPanel();
    topLevel.setLayout (new BorderLayout());
    getContentPane().add (topLevel);        

    JPanel buttonPanel = new JPanel();

    buttonPanel.add (new JLabel ("Visibility"));
    
    geometryToggle_ = new JCheckBox ("Geometry");
    geometryToggle_.setSelected (true);
    buttonPanel.add (geometryToggle_);
    geometryToggle_.addActionListener (this);
    
    annotationToggle_ = new JCheckBox ("Annotation");    
    annotationToggle_.setSelected (true);
    buttonPanel.add (annotationToggle_);
    annotationToggle_.addActionListener (this);
    
    topLevel.add (buttonPanel, BorderLayout.NORTH);

    // Create the graphic canvas
    GWindow window = new GWindow (new Color (245250236));
    topLevel.add (window.getCanvas(), BorderLayout.CENTER);    
    
    // Create scene with default viewport and world extent settings
    scene_ = new GScene (window, "Scene");

    // Create som graphic objects
    GObject testObject = new TestObject (20);
    scene_.add (testObject);

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


  
  /**
   * Handle button interactions.
   
   @param event  Event causing call to this method.
   */
  public void actionPerformed (ActionEvent event)
  {
    Object source = event.getSource();

    boolean showGeometry   = geometryToggle_.isSelected();
    boolean showAnnotation = annotationToggle_.isSelected();

    if (showGeometry)   scene_.setVisibility (GObject.DATA_VISIBLE);
    else                scene_.setVisibility (GObject.DATA_INVISIBLE);
    
    if (showAnnotationscene_.setVisibility (GObject.ANNOTATION_VISIBLE);
    else                scene_.setVisibility (GObject.ANNOTATION_INVISIBLE);

    scene_.refresh();
  }


  
  /**
   * Defines the geometry and presentation for the sample
   * graphic object.
   */   
  private class TestObject extends GObject
  {
    private GSegment[]  lines_;

    
    TestObject (int nLines)
    {
      lines_ = new GSegment[nLines];

      GStyle textStyle = new GStyle();
      textStyle.setForegroundColor (new Color (000));
      textStyle.setFont (new Font ("Dialog", Font.BOLD, 14));      
      
      for (int i = 0; i < nLines; i++) {
        lines_[inew GSegment();
        GStyle lineStyle = new GStyle();
        lineStyle.setForegroundColor (new Color ((floati / nLines, 0.7f0.7f));
        lineStyle.setLineWidth (3);
        lineStyle.setAntialiased (true);
        lineStyle.setLineStyle (new float[] {10.0f5.0f2.0f5.0f});
        lines_[i].setStyle (lineStyle);
        addSegment (lines_[i]);
        
        GText text = new GText ("Line " (i+1), GPosition.BOTTOM | GPosition.CENTER);
        text.setStyle (textStyle);
        lines_[i].setText (text);
      }
    }

    
    public void draw()
    {
      // Center of viewport
      int x0     = (intMath.round (getScene().getViewport().getCenterX());
      int y0     = (intMath.round (getScene().getViewport().getCenterY());

      int width  = (intMath.round (getScene().getViewport().getWidth());
      int height = (intMath.round (getScene().getViewport().getHeight());

      int nLines = lines_.length;
      for (int i = 0; i < nLines; i++) {
        int x1 = x0;
        int y1 = 0;
        int x2 = (intMath.round ((doublewidth / nLines * i);
        int y2 = height;

        lines_[i].setGeometry (x1, y1, x2, y2);
      }
    }
  }
  


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

           
       
G-DrawRadiation.zip( 200 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 String and StarDraw String and Star
w__w_w___.j___av___a__2_s___.__c__om___ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.