Java 2D Graphics

Java 2D Graphics

I am working on GIS project.I want represent a line in different forms like railroad, airplane etc.
How can i acheive this
I know the standard forms like dashed, dotted line.My code is

bs = null;
bs = new BasicStroke(files[i].getSizeLineString(), files[i].getEndStyleLineString(), files[i].getJoinStyleLineString()/**,1.0f,new float[] {5},0*/);
g2.setStroke(bs);
//bs = null;
// bs = new BasicStroke(files[i].getSizeLineString(), files[i].getEndStyleLineString(), files[i].getJoinStyleLineString());

WGS_LineString[] lineString = files[i].getLineString();
for (int j = 0; j < lineString.length; j++) {
g2.setColor(files[i].getLineStringColor());
double[] x = lineString[j].getX();
double[] y = lineString[j].getY();
int[] x1 = new int[x.length];
int[] y1 = new int[y.length];
for (int k = 0; k < x.length; k++) {
x1[k] = (int) ((x[k] - deltaX) * zoomunit) + shiftUnit;
y1[k] = (int) ((deltaY - y[k]) * zoomunit) + shiftUnit;
}
if(Global.index1==0){

if(Global.getTrasperency()&& Global.FileWithTransparency.containsKey(files[i]))
{
int m=(Integer)Global.FileWithTransparency.get(files[i]);
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, m* 0.1f));
g2.drawPolyline(x1, y1, x1.length);
}
else
{
if(Global.isThematicMode() && files[i].isActive())
{
String value="";
if(Global.getThematicSubmode().equals("SingleField"))
value=(String)lineString[j].getRecordByAttribute(Global.getThematicAttribute());
else if(Global.getThematicSubmode().equals("MultiField"))
{
String key=Global.getThematicAttribute();
String []field1=new String[2];
if(key.contains("@@ "))
{
field1=key.split("@@ ");
value=((String)lineString[j].getRecordByAttribute(field1[0])).trim()+" , "+((String)lineString[j].getRecordByAttribute(field1[1])).trim();
}
else
value=(String) lineString[j].getRecordByAttribute(key);
}
else
value="FID"+Integer.toString(i).trim()+"."+Integer.toString(j).trim();
Color drawline=(Color)Global.thematicHash.get(value);
g2.setColor(drawline);
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 10* 0.1f));
g2.drawPolyline(x1, y1, x1.length);
value="";
}
else
{
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 10* 0.1f));
g2.drawPolyline(x1, y1, x1.length);
}
}
}
View Answers

January 28, 2010 at 3:51 PM

Hi Friend,

Please visit the following link:

http://www.roseindia.net/java/example/java/swing/graphics2D/

Here you will get lot of examples.

Hope that it will be helpful for you.
Thanks









Related Tutorials/Questions & Answers:
Java 2D Graphics - Applet
Java 2D Graphics  I am working on GIS project.I want represent a line in different forms like railroad, airplane etc. How can i acheive this I know...://www.roseindia.net/java/example/java/swing/graphics2D/ Here you will get lot
java 2d graphics - Java Beginners
java 2d graphics  Hello All I need to use 2d graphics in java to build up a map from the given geographic coordinates. What i am not getting is how to scale down these geographic coordinates to device coordinates. I would
Advertisements
Java 2D
Java 2D  Hi, What is Java 2D? Thanks   Hi, Please see it at Java 2D API. Thanks
Graphics 2D
Graphics 2D      ....    Noise Image in Graphics This Java Tutorial is all about creating Images with the use of graphics in Java. For this we
java graphics
java graphics  Name three Component subclasses that support painting
java 2d arrays
java 2d arrays  Create a program that will: a) Create the array and populate it with the given values. 9, 8 2, 17 49, 4 13, 119 2, 19 11, 47 3, 73 b) Multiply, for each row, the value of the first column by the value
graphics - Java Beginners
graphics  In java-graphics.. I want to draw a rectangle and resize that rectangle(small,big) ..by using mouse cursors
Java Graphics Programming
Java Graphics Programming  Hi<BR> I am newbie to java and I have written a code in java that creates a window in which a line and rectangle...;BR> public void paint(Graphics g)<BR> {<BR> g.setColor
Java 2D API
Java 2D API       Programming has become more interactive with Java 2D API. You can add images... since Swing is built on 2D package. Pluggable Look and Feel  The Java Swing
How to draw in jPanel? swing/graphics Java
How to draw in jPanel? swing/graphics Java  How to draw in jPanel? (swing/graphics Java
2d arrays
2d arrays  what is the code for multiplying the values in a 2d array and printing out their sum
java code along wid graphics design
java code along wid graphics design  actually i want to design nd make an apllication to solve a rubics cube of 3*3.. i have an algos wid me bt jus need ur guidance..plzz hlp out or if u have ny other ideas do suggest
how to find inverse of n*n 2d array in java
how to find inverse of n*n 2d array in java  I reached upto code of printing the matrix as: Assume that matrix is square matrix where row=column code is: public class ReadContents{ public static void main(String args
java graphics - Design concepts & design patterns
java graphics  i dont wanna use Java3D but put solid 3D objects on screen, use z-buffering, ray-casting etc. to make realistic images...this will help build 3D fractals etc...Where must i begin reading
using 2D Array
using 2D Array  Write a JAVA program using 2D Array to auto-grade exams. For a class of N students, your program should read letter answers (A, B, C, D) for each student. Assume there are 5 questions in the test. Your program
using 2D Array
using 2D Array  Write a JAVA program using 2D Array to auto-grade exams. For a class of N students, your program should read letter answers (A, B, C, D) for each student. Assume there are 5 questions in the test. Your program
graphics program
graphics program  i want a program that implements merge sort algorithm in graphics
how to draw lines,circles, rectangles on JSP (using Java Graphics)
how to draw lines,circles, rectangles on JSP (using Java Graphics)  how to draw lines,circles, rectangles on JSP (using Java Graphics)   ...); // Get drawing context Graphics g = image.getGraphics(); // Fill background
Java get Graphics
Java get Graphics     ... image.getGraphics() returns the Graphics object. The method...(400,400,BufferedImage.TYPE_INT_ARGB);   Graphics graphics
Maven dependency for com.googlecode.blaisemath - blaise-graphics version 3.0.13 is released. Learn to use blaise-graphics version 3.0.13 in Maven based Java projects
( com.googlecode.blaisemath - blaise-graphics version 3.0.13 ) in their Java project... - blaise-graphics version 3.0.13 in Java projects. Follow the step by step tutorial... of blaise-graphics released The developers of  
Maven dependency for com.googlecode.blaisemath - blaise-graphics version 3.0.8 is released. Learn to use blaise-graphics version 3.0.8 in Maven based Java projects
( com.googlecode.blaisemath - blaise-graphics version 3.0.8 ) in their Java project... - blaise-graphics version 3.0.8 in Java projects. Follow the step by step... - blaise-graphics version 3.0.8 java library in your project. ADS
Maven dependency for com.googlecode.blaisemath - blaise-graphics version 3.0.4 is released. Learn to use blaise-graphics version 3.0.4 in Maven based Java projects
( com.googlecode.blaisemath - blaise-graphics version 3.0.4 ) in their Java project... - blaise-graphics version 3.0.4 in Java projects. Follow the step by step... - blaise-graphics version 3.0.4 java library in your project. ADS
Maven dependency for com.googlecode.blaisemath - blaise-graphics version 2.2.21 is released. Learn to use blaise-graphics version 2.2.21 in Maven based Java projects
( com.googlecode.blaisemath - blaise-graphics version 2.2.21 ) in their Java project...; com.googlecode.blaisemath - blaise-graphics version 2.2.21 in Java projects. Follow the step by step...; com.googlecode.blaisemath - blaise-graphics version 2.2.21 java library in your project. ADS
iPhone Graphics
iPhone Graphics  Hi, How to create iPhone Graphics? I am learning to crate UI Design for iPhone and iPad. Thanks
graphics - Java Beginners
Storing the Color Image pixel values into 2d array
Storing the Color Image pixel values into 2d array  i want to store the color image pixel values into 2d array and agiain the array have to store into a text file using java... plz provide the code
Concatenate 2D arrays
Concatenate 2D arrays  JFileChooser jf = new JFileChooser(); jf.setMultiSelectionEnabled(true); int returnVal = jf.showOpenDialog(frame); File...://www.roseindia.net/tutorial/java/poi/readExcelFile.html
Changing 2D graph using slider.
Changing 2D graph using slider.  Code for changing a 2d graph with help of slider
FXG graphics
FXG graphics  Hi.... What is FXG in flex4? can you give me the explanation about it.. ThanksADS_TO_REPLACE_1   Ans: FXG: FXG is a declarative syntax for defining static graphics. You typically use a graphics tool
how to print the average of each column of 2d n*m array using java
how to print the average of each column of 2d n*m array using java  here is my code: import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Scanner; public
ModuleNotFoundError: No module named 'graphics'
ModuleNotFoundError: No module named 'graphics'  Hi, My Python... 'graphics' How to remove the ModuleNotFoundError: No module named 'graphics... to install padas library. You can install graphics python with following
Graphics class in flex
Graphics class in flex  Hi.... What does clear() do in graphics class? please tell me about that....ADS_TO_REPLACE_1 Thanks   Ans: Clears the graphics that were drawn to this Graphics object, and resets fill
Version of com.lib16>graphics dependency
List of Version of com.lib16>graphics dependency
Selecting elements of 2D array with GUI
Selecting elements of 2D array with GUI  Hello! I am building a Java application with GUI (JFrame form) that is supposed to display all or selected elements of below 2D array (images attached): Year Season 2002 2003
Noise Image in Graphics
of graphics in Java. For this we have to import awt and swing package in our Java code... created in java using graphics... Noise Image in Graphics      
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for graphics version 1.1.1
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for graphics version 1.1.1. You can add these depency in your project to get com.lib16:graphics:1.1.1 Java library in your project.. Maven, Gradle, SBT, Ivy, Grape
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for graphics version 1.1
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for graphics version 1.1. You can add these depency in your project to get com.lib16:graphics:1.1 Java library in your project.. Maven, Gradle, SBT, Ivy, Grape, Leiningen
Noise Image in Graphics
of graphics in Java. For this we have to import awt and swing package in our Java code... that we have created in java using graphics.  ADS_TO_REPLACE_5... Noise Image in Graphics     
Add RenderingHints to a Graphics
Add RenderingHints to a Graphics       This Java tutorial teaches you about adding the rendering hints to a graphics on the frame. The rendering hints uses the Graphics2D and creates
ModuleNotFoundError: No module named 'gillcup_graphics'
ModuleNotFoundError: No module named 'gillcup_graphics'  Hi, My... named 'gillcup_graphics' How to remove the ModuleNotFoundError: No module named 'gillcup_graphics' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'simple-graphics'
ModuleNotFoundError: No module named 'simple-graphics'  Hi, My... named 'simple-graphics' How to remove the ModuleNotFoundError: No module named 'simple-graphics' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'tensorflow-graphics'
ModuleNotFoundError: No module named 'tensorflow-graphics'  Hi, My... named 'tensorflow-graphics' How to remove the ModuleNotFoundError: No module named 'tensorflow-graphics' error? Thanks   Hi
ModuleNotFoundError: No module named 'text-graphics'
ModuleNotFoundError: No module named 'text-graphics'  Hi, My... 'text-graphics' How to remove the ModuleNotFoundError: No module named 'text-graphics' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'ai-graphics'
ModuleNotFoundError: No module named 'ai-graphics'  Hi, My Python... 'ai-graphics' How to remove the ModuleNotFoundError: No module named 'ai-graphics' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'gillcup_graphics'
ModuleNotFoundError: No module named 'gillcup_graphics'  Hi, My... named 'gillcup_graphics' How to remove the ModuleNotFoundError: No module named 'gillcup_graphics' error? Thanks   Hi, In your
What is Web Graphics
What is Web Graphics Web graphics.... An excellent designed graphics can give better and creative ideas to customer of what they are looking for. Web graphics helps designers to enhance
Maven Dependency graphics >> 1.1
You should include the dependency code given in this page to add Maven Dependency of com.lib16 >> graphics version1.1 in your project
Maven Dependency graphics >> 1.1.1
You should include the dependency code given in this page to add Maven Dependency of com.lib16 >> graphics version1.1.1 in your project
code to display images using 2d array - Swing AWT
code to display images using 2d array  HI !! I have an image file in ascii/binary format (lines & pixels) in the form of a 2d-array. I would like to display this using java code. I am relatively new to coding
ModuleNotFoundError: No module named 'linaro-graphics-dashboard'
ModuleNotFoundError: No module named 'linaro-graphics-dashboard'  Hi...: No module named 'linaro-graphics-dashboard' How to remove the ModuleNotFoundError: No module named 'linaro-graphics-dashboard' error? Thanks  

Ads