Home Answers Viewqa Applet Java 2D Graphics

 
 


nagarjuna
Java 2D Graphics
1 Answer(s)      3 years and 4 months ago
Posted in : Applet

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 Pages:
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
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 2D
Java 2D  Hi, What is Java 2D? Thanks   Hi, Please see it at Java 2D API. Thanks
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
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
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
graphics - Java Beginners
graphics  In java-graphics.. I want to draw a rectangle and resize that rectangle(small,big) ..by using mouse cursors
Graphics class
Java NotesGraphics class Description The Graphics class contains drawing methods. A Graphics object is passed to your paintComponent(Graphics g). You... equal to the height. Advanced There are also Graphics methods for drawing images
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
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
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
Summary: Graphics
Java: Summary: Graphics This is a summary of simple graphics methods... classes define more advanced graphics, eg, javax.swing.Graphics2D. Related... methods Draw on a JPanel. Assume g is a Graphics object, and all variables
Summary: GUI Graphics
Java: Summary: GUI Graphics This is a summary of simple graphics methods... classes define more advanced graphics, eg, javax.swing.Graphics2D. java.awt.Graphics Class Draw on a JPanel. Assume g is a Graphics object, and all
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
2d arrays
2d arrays  what is the code for multiplying the values in a 2d array and printing out their sum
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
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
Create Human Face using Graphics
Create Human Face using Graphics In this section, you will learn how to create human face using Graphics. A Graphics provides contexts that allow... off-screen images. The Graphics class provides several methods through which we
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... Noise Image in Graphics      
Java get Graphics
Java get Graphics     ... image.getGraphics() returns the Graphics object. The method...(400,400,BufferedImage.TYPE_INT_ARGB);   Graphics graphics=image.getGraphics
Noise Image in Graphics
of graphics in Java. For this we have to import awt and swing package in our Java code... a noise image that we have created in java using graphics.  ... 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
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)   ... context Graphics g = image.getGraphics(); // Fill background g.setColor(Color.white
graphics program
graphics program  i want a program that implements merge sort algorithm in graphics
iPhone Graphics
iPhone Graphics  Hi, How to create iPhone Graphics? I am learning to crate UI Design for iPhone and iPad. Thanks
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
FXG graphics
FXG graphics  Hi.... What is FXG in flex4? can you give me the explanation about it.. Thanks   Ans: FXG: FXG is a declarative syntax for defining static graphics. You typically use a graphics tool such as Adobe
Changing 2D graph using slider.
Changing 2D graph using slider.  Code for changing a 2d graph with help of slider
Graphics class in flex
Graphics class in flex  Hi.... What does clear() do in graphics class? please tell me about that.... Thanks   Ans: Clears the graphics that were drawn to this Graphics object, and resets fill and line style settings
Antialiasing
Java: Antialiasing Antialiased versus Aliased Graphics  ....   This can be avoided in Java 2's Graphics2D class by requesting that edges are antialiased. public void paintComponent(Graphics g
Graphics Designer Jobs
Graphics Designer Jobs       Position Vacant: Web Graphics Designer Company Name: Rose India... Weaver hands-on experience Flash hands-on experience Good Knowledge of Java
Graphics2D
Java: Graphics2D The javax.swing.Graphics2D class of Java 2 supports many more graphics operations than the Graphics class. For example, Graphics2D..., skewing) [list many others, this is only a rough beginning] Graphics
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
How to Create Circle In Java
fundamental abstractions in a Java 2D in the supported  java.awt.shape package. It describes a shape. But the Java 2D definition of a shape does not require... How to Create Circle In Java     
Show Graphics on full Screen
.style1 { margin-right: 140px; } Show Graphics...; This section illustrates you how to show graphics on full screen. To display the graphics, we have used the class DisplayMode which provides the bit depth
Read text file to 2D array and sorting the second column
Read text file to 2D array and sorting the second column  we found that the student names with marks in a text file the marks decreases significantly. when exams conducted fast 4 times.The first column is the student name
Event Dispatcher Thread
Event Dispatcher Thread       In the tutorial Java Event Dispatcher thread in Graphics, we'll illustrate you how to handle events in graphics using Java. This example
Event Dispatcher Thread
Event Dispatcher Thread       In the tutorial Java Event Dispatcher thread in Graphics, we'll illustrate you how to handle events in graphics using Java. This example
how to find subarray from given large 2d array of arbritary dimension
how to find subarray from given large 2d array of arbritary dimension  my code is: import java.lang.*; import java.io.*; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; import
Bouncing Thread Example
Bouncing Thread Example       In this section, we are going to develop a small Java Graphics application that creates a ball which bounce with the help of thread in Graphics
Bouncing Thread Example
Bouncing Thread Example       In this section, we are going to develop a small Java Graphics application that creates a ball which bounce with the help of thread in Graphics
How To Connect MS ACCESS 2003 Database in C Program with Graphics.
How To Connect MS ACCESS 2003 Database in C Program with Graphics.  How To Connect MS ACCESS 2003 Database in C Program with Graphics
Example - CirclePanel.java
Java NotesExample - CirclePanel.java Problem: The Java Graphics class... //=========================================== paintComponent public void paintComponent(Graphics g... // Convenience method to draw from center with radius public void drawCircle(Graphics cg

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.