Draw Line With Arrow between containers in flex
I need to connect multiple containers by drawing arrow . can any one provide me the idea how to do?
Thanks in Advance,
senthil
[email protected]
If your containers are within a spark container them self then you could use fxg to draw arrows based on the containers boundaries
eg this code will draw a red arrow:
<Graphic xmlns="http://ns.adobe.com/fxg/2008" version="2"> <!-- Use Use compact syntax with absolute coordinates. --> <Path data=" M 20 0 C 50 0 50 35 20 35 L 15 35 L 15 45 L 0 32 L 15 19 L 15 29 L 20 29 C 44 29 44 6 20 6"> <!-- Define the border color of the arrow. --> <stroke> <SolidColorStroke color="#888888"/> </stroke> <!-- Define the fill for the arrow. --> <fill> <LinearGradient rotation="90"> <GradientEntry color="#000000" alpha="0.8"/> <GradientEntry color="#FFFFFF" alpha="0.8"/> </LinearGradient> </fill> </Path> </Graphic>
you will have to scale the arrow according to your needs
Similar Messages
-
Can j2me draw line with double values.
Hi,
Can any body know how to darw line in j2me with double values.
I don't want use draw Line with int.
Shall i use svg or j2me has solution.
Thanks and regards,
Rakesh.not possible
graphics.drawLine(float,float,float,float);...there's no such method in MIDP API: [click here for javadoc of Graphics class methods|http://java.sun.com/javame/reference/apis/jsr118/javax/microedition/lcdui/Graphics.html#drawLine(int,%20int,%20int,%20int)] -
Draw line with float values possible
Hi,
Using Canvas drawing is possible to draw line with float values.
graphics.drawLine(int,int,int,int);
graphics.drawLine(float,float,float,float);Thanks and regards,
Rakesh.not possible
graphics.drawLine(float,float,float,float);...there's no such method in MIDP API: [click here for javadoc of Graphics class methods|http://java.sun.com/javame/reference/apis/jsr118/javax/microedition/lcdui/Graphics.html#drawLine(int,%20int,%20int,%20int)] -
How to make a line with arrow curve around a circle?
I've got CS6 and Windows 7. Trying to make a line with an arrow on one end curve around a circle. Actually want it to have a 3D look like it was curving around the back side of a globe. How do you do this? Thanks.
Perhaps you mean something more like this
similar technique you create the arrow as a straight stroke path with an arrowhead and make it a symbol
You then make it a symbol
you than make a vertical rectangle and use the 3D Revolve Effect to make a cylinder
then you go to map art
then you choose in the map art to make the geomtery invisible
then you ma the arrow symbol and adjust the placement and then adjust the rotation of the cylinder to your likeing.
If you need a video to follow I'll do one later. -
Drawing lines with smooth curves
Hi,
I'm trying to make a map for an underground system in a PC game and I want something similar to the one Transport for London has:
http://www.tfl.gov.uk/assets/downloads/standard-tube-map.gif
I'm a total newbie with Adobe Illustrator, but I'm trying it as I've heard it's what Transport for London uses.
My question is then, what would be the easiest way of accomplishing multiple lines with different colours and smooth curves, like the lines in my reference picture?
Thanks in advance,
MartinMartin,
In addition to what Kurt said, you may draw paths with straight segments and then round the corners afterwards, using Effect>Stylise>Round Corners (you may Object>Expand Appearance to obtain actual roundings). -
How to draw line with width at my will
Dear frineds:
I have following code to draw lines, but I was required:
[1]. draw this line with some required width such as 0.2 or 0.9 or any width at my will
[2]. each line after I draw, when I use mouse to click on it, it will be selected and then I can delete it,
Please advice how to do it or any good example??
Thanks
sunny
package com.draw;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class DrawingArea extends JPanel
Vector angledLines;
Point startPoint = null;
Point endPoint = null;
Graphics g;
public DrawingArea()
angledLines = new Vector();
setPreferredSize(new Dimension(500,500));
MyMouseListener ml = new MyMouseListener();
addMouseListener(ml);
addMouseMotionListener(ml);
setBackground(Color.white);
public void paintComponent(Graphics g)
// automatically called when repaint
super.paintComponent(g);
g.setColor(Color.black);
g.setFont(getFont());
AngledLine line;
if (startPoint != null && endPoint != null)
// draw the current dragged line
g.drawLine(startPoint.x, startPoint.y, endPoint.x,endPoint.y);
for (Enumeration e = angledLines.elements(); e.hasMoreElements();)
// draw all the angled lines
line = (AngledLine)e.nextElement();
g.drawPolyline(line.xPoints, line.yPoints, line.n);
class MyMouseListener extends MouseInputAdapter
public void mousePressed(MouseEvent e)
if (SwingUtilities.isLeftMouseButton(e))
startPoint = e.getPoint();
public void mouseReleased(MouseEvent e)
if (SwingUtilities.isLeftMouseButton(e))
if (startPoint != null)
AngledLine line = new AngledLine(startPoint, e.getPoint(), true);
angledLines.add(line);
startPoint = null;
repaint();
public void mouseDragged(MouseEvent e)
if (SwingUtilities.isLeftMouseButton(e))
if (startPoint != null)
endPoint = e.getPoint();
repaint();
public void mouseClicked( MouseEvent e )
if (g == null)
g = getGraphics();
g.drawRect(10,10,20,20);
class AngledLine
// inner class for angled lines
public int[] xPoints, yPoints;
public int n = 2;
public AngledLine(Point startPoint, Point endPoint, boolean left)
xPoints = new int[n];
yPoints = new int[n];
xPoints[0] = startPoint.x;
xPoints[1] = endPoint.x;
yPoints[0] = startPoint.y;
yPoints[1] = endPoint.y;
/*if (left)
xPoints[1] = startPoint.x;
yPoints[1] = endPoint.y;
else
xPoints[1] = endPoint.x;
yPoints[1] = startPoint.y;
public static void main(String[] args)
JFrame frame = new JFrame("Test angled lines");
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
DrawingArea d = new DrawingArea();
frame.getContentPane().add( d );
frame.pack();
frame.setVisible(true);
}Message was edited by:
sunnymanmansonudevgan wrote:
dear piz tell me how i can read integer from user my email id is [email protected]
foolish, foolish question -
Hi,
I am trying to implement drawing on canvas with two colors, red and blue.
For example, to draw with the mouse "with two colors".
I do not need a filled rectangle.
I am looking into gradient but without any success.
Is there a better way to draw a line with two colors?
I also tried to use BasicStroke, but the line had an inner/outer strokes.
Please help with suggestions.devboris wrote:
..For example, to draw with the mouse "with two colors".
import java.awt.*;
import javax.swing.*;
class GradientLine {
public static void main(String[] args) {
GradientPanel gp = new GradientPanel();
gp.setPreferredSize( new Dimension(600,400) );
JOptionPane.showMessageDialog(null, gp);
class GradientPanel extends JPanel {
public void paintComponent(Graphics g) {
// cast the Graphics objkect to a Graphics2D object
// (G2D includes setPaint() method)
Graphics2D g2 = (Graphics2D)g;
GradientPaint bgPaint = new GradientPaint(
0,
0,
Color.black,
getWidth(),
getHeight(),
Color.white );
g2.setPaint(bgPaint);
g2.fillRect( 0, 0, getWidth(), getHeight() );
GradientPaint fgPaint = new GradientPaint(
0,
0,
Color.yellow,
getWidth(),
getHeight(),
Color.red );
// set the paint to a gradient.
g2.setPaint(fgPaint);
for (int ii=0; ii<getWidth()/10; ii++) {
g2.drawLine( ii*10, 0, ii*10, getHeight() );
for (int ii=0; ii<getHeight()/10; ii++) {
g2.drawLine( 0, ii*15, getWidth(), ii*15 );
} -
How to draw a line with arrow head
Hi,
I have an application where i need to connect different
components by line. I am able to connect the components by line but
i dont know how i can add arrow to the line head or one end of
line. When i drag line from a souce component to destination the
line end at destination must have a pointed head i.e arrow.
If any one have solution please reply..
Thank you.Hi,
I have an application where i need to connect different
components by line. I am able to connect the components by line but
i dont know how i can add arrow to the line head or one end of
line. When i drag line from a souce component to destination the
line end at destination must have a pointed head i.e arrow.
If any one have solution please reply..
Thank you. -
Moving a line with arrow keys/can't adjust distance
In Illustrator CS6 I can't adjust how far a line moves when I move it using the arrow keys. I've gone to Preferences>General>Keyboard Increment and changed the amount, but the line moves the same distance no matter what I put in. Neither Snap to Grid nor Snap to Point are turned on.
Thank you Mike! It was driving me crazy. I just started to use CS6 and hadn't messed with any adjustments. How would someone know to check such a seemingly obscure--except to come to the forum?
-
Drawing line with button??
Hi all.
Why won't this class draw a line when i click the mouse button. Nothing happens when i click on the panel.
import java.util.*;
import java.awt.*;
import javax.swing.JPanel;
import javax.swing.*;
import javax.swing.Action.*;
import java.awt.event.*;
import java.awt.event.MouseAdapter;
public class DrawingPanel extends JPanel implements Observer
private ViewableEtch etch;
private ClearPanel clear;
public DrawingPanel(ViewableEtch etch, ClearPanel clear)
this.etch = etch;
this.clear = clear;
etch.addView(this);
clear.addView(this);
setLayout(new FlowLayout());
setLayout(new GridLayout(200,200));
//etch.addActionListener(this);
DrawingControl dc = new DrawingControl();
public void update(Observable obs, Object obj)
Views v = (Views)obs;
if (v.getSource() == etch)
//etch.getLineColor();
getGraphics().setColor(etch.getLineColor() );
getGraphics().drawLine(etch.getStartX(), etch.getStartY(), etch.getEndX(), etch.getEndY());
else
v.getSource().equals(clear);
public void mouseClicked(MouseEvent e)
//etch.setLine(new etch(getStartX(), getStartY(), e.getEndX(), e.getEndY()));
getGraphics().drawLine(etch.getStartX(), etch.getStartY(), etch.getEndX(), etch.getEndY());
}thanxThis should work
public class MyPanel extends JPanel implements MouseListener {
public MyPanel() {
addMouseListener(this);
public void mouseClicked(MouseEvent e) {
// Add code here
public void mouseEntered(MouseEvent e) {}
public void mouseExited(MouseEvent e) {}
public void mousePressed(MouseEvent e) {}
public void mouseReleased(MouseEvent e) {} -
Draw lines with a specfic width and color
how to do it?
if given x arrays and y arrays, then connect points.
public void drawLine(int x1, int y1, int x2, int y2)This function doesn't have width and color.thanks.
I met a problem that the color is obtained by
calculating RGB.
color=a*R+b*G+c*B;
a+b+c=1;
How to get it?huh? -
How to implement container with dividers between elements?
What is the correct way to implement custom container with dividers between element in Flex 4 Spark architecture? In Flex 3 I would add dividers in rawChildren array and in updateDisplayList function I would arrange position of dividers and children. I can't do this now because there is no rawChildren and I can't add dividers as elements, because dividers are internal details of control and they should not be available to user. I thought to add second group with dividers, but the layout of splitters depends on the layout of actual content. With new model of separated layouts for Groups I don't know how do this correctly.
Thanks, AlekseyWhat is the correct way to implement custom container with dividers between element in Flex 4 Spark architecture? In Flex 3 I would add dividers in rawChildren array and in updateDisplayList function I would arrange position of dividers and children. I can't do this now because there is no rawChildren and I can't add dividers as elements, because dividers are internal details of control and they should not be available to user. I thought to add second group with dividers, but the layout of splitters depends on the layout of actual content. With new model of separated layouts for Groups I don't know how do this correctly.
Thanks, Aleksey -
Drawing an arrow between two rectangle shapes
i am trying to draw an arrow between two rectangle shapes. the arrow will start from the center of one rectangle and end with the arrow tip at the edge of the other rectangle. i actually draw the arrow first, and draw the rectangles last so the effect of where the arrow starts will seem to come from the edge and not the center.
i have code using some trigonmetry that works for squares, but as soon as the shape becomes a rectangle (i.e. width and height are not the same), the drawing breaks.
can i detect where a line intersects with a shape through clipping and use that point location to draw my arrow head? if so, how?Here's one way to do this using the rule of similar triangles.
import java.awt.*;
import java.awt.geom.*;
import javax.swing.*;
public class Pointers extends JPanel {
Rectangle r1 = new Rectangle(40,60,100,150);
Rectangle r2 = new Rectangle(200,250,175,100);
int barb = 20;
double phi = Math.toRadians(20);
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2.setPaint(Color.blue);
g2.draw(r1);
g2.draw(r2);
g2.setPaint(Color.red);
g2.draw(getPath());
private GeneralPath getPath() {
double x1 = r1.getCenterX();
double y1 = r1.getCenterY();
double x2 = r2.getCenterX();
double y2 = r2.getCenterY();
double theta = Math.atan2(y2 - y1, x2 - x1);
Point2D.Double p1 = getPoint(theta, r1);
Point2D.Double p2 = getPoint(theta+Math.PI, r2);
GeneralPath path = new GeneralPath(new Line2D.Float(p1, p2));
// Add an arrow head at p2.
double x = p2.x + barb*Math.cos(theta+Math.PI-phi);
double y = p2.y + barb*Math.sin(theta+Math.PI-phi);
path.moveTo((float)x, (float)y);
path.lineTo((float)p2.x, (float)p2.y);
x = p2.x + barb*Math.cos(theta+Math.PI+phi);
y = p2.y + barb*Math.sin(theta+Math.PI+phi);
path.lineTo((float)x, (float)y);
return path;
private Point2D.Double getPoint(double theta, Rectangle r) {
double cx = r.getCenterX();
double cy = r.getCenterY();
double w = r.width/2;
double h = r.height/2;
double d = Point2D.distance(cx, cy, cx+w, cy+h);
double x = cx + d*Math.cos(theta);
double y = cy + d*Math.sin(theta);
Point2D.Double p = new Point2D.Double();
int outcode = r.outcode(x, y);
switch(outcode) {
case Rectangle.OUT_TOP:
p.x = cx - h*((x-cx)/(y-cy));
p.y = cy - h;
break;
case Rectangle.OUT_LEFT:
p.x = cx - w;
p.y = cy - w*((y-cy)/(x-cx));
break;
case Rectangle.OUT_BOTTOM:
p.x = cx + h*((x-cx)/(y-cy));
p.y = cy + h;
break;
case Rectangle.OUT_RIGHT:
p.x = cx + w;
p.y = cy + w*((y-cy)/(x-cx));
break;
default:
System.out.println("Non-cardinal outcode: " + outcode);
return p;
public static void main(String[] args) {
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(new Pointers());
f.setSize(400,400);
f.setLocation(200,200);
f.setVisible(true);
} -
Hi All,
I want to draw multiple line with a arrow. Please guide me how can i do it by code dynamically. exactly as below.
Regards,
Kameshwaran A.create an empty symbol
put this code in it.
//***** Set some opening parameters
onClipEvent (load) {
//Make original line invisible
_root.line._visible = 0;
//Initiate some variables
number_lines = 0;
line_active = 0;
//***** Every time the mouse button is released...
onClipEvent (mouseUp) {
//Get the position of the mouse
origin_x = _xmouse;
origin_y = _ymouse;
//Increase the number of lines by one
number_lines++;
//Generate a new line name
name = "line"+number_lines;
//Duplicate a new line
_root.line.duplicateMovieClip(name, number_lines);
//Position the line's end point at mouse position
_root[name]._x = origin_x;
_root[name]._y = origin_y;
//Update line length / orientation
_root[name]._xscale = _root._xmouse-origin_x;
_root[name]._yscale = _root._ymouse-origin_y;
//If this is the start of a new shape
if (!line_active)
//Set the line tracking variable
line_active = 1;
//Set the start point of the new shape
start_x = origin_x;
start_y = origin_y;
//***** Every time the mouse is moved
onClipEvent (mouseMove) {
//If there's a line currently being drawn...
if (line_active)
//Update line length / orientation
_root[name]._xscale = _root._xmouse-origin_x;
_root[name]._yscale = _root._ymouse-origin_y;
updateAfterEvent();
//***** When a key is pressed
onClipEvent (enterFrame) {
//If it's the Enter key
if (Key.isDown(Key.ENTER))
//Join the end point of this line...
//...to the start point of the first line in this shape
_root[name]._xscale = "";
_root[name]._yscale = "";
//Reset line-tracking variable
line_active = 0;
draw a line convert it to a symbol and give it an instance name of line.
and there you can draw lines.
detach the lines by pressing enter.
and thats it.
your welcome in advance (:
INPORTANT to leave all your symbols in the scene not in the libery are it will not work
Message was edited by: xFARRELLx -
Using a keyListener to draw with arrow keys
Hi!
I am trying to create an interactive game where the user can
draw a line using the arrow keys (similar to an etch-a-sketch). I
have a start point acting on keyListeners that will move around the
screen using the arrow keys, but I can't seem to figure out how to
get the listeners to draw a line. Here is the correct code that
moves the start point:
information_txt.text = "USE YOUR ARROW KEYS TO DRAW";
var speed:Number = 4;
start_mc.onEnterFrame = function() {
if (Key.isDown(Key.RIGHT)) {
this._x = this._x+speed;
} else if (Key.isDown(Key.LEFT)) {
this._x = this._x-speed;
if (Key.isDown(Key.UP)) {
this._y = this._y-speed;
} else if (Key.isDown(Key.DOWN)) {
this._y = this._y+speed;
How can I modify Action Script to get the keyListeners to
draw on the arrow keys?
Any help would be MUCH appreciated!!!
Thanks!Thanks for your reply! That's awesome. you were right, my
script is in AS 2.0... I guess I posted to the wrong section. But I
could easily switch to AS 3.0. I am really just interested in
drawing with the arrow keys and using that action script to draw
onto my own stage/ image. I have tried messing with the script, but
can't seem to get the "drawing" portions of the script to work.
Any suggestions??
Thanks again for the help!!!
Maybe you are looking for
-
Dear All I have a requirement where clients want to pass duty for partial quantity from GR. Kindly let me know if we can process partial quantity. We want to post excise invoice for Depot for partial quantity - RG23D to be updated I tried doing the s
-
Simultaneously Controlling LabVIEW Remote Front Panels not working properly
We are trying to simultaneously control a Executable file from different PC as per the description given in link below: http://www.ni.com/white-paper/4867/en But the issue is that we are not able to view it in Web browser as in "Web Publishing tool"
-
SMQ2 Error "Screen output without connection to user"
Hi All, In the SMQ2 in CRM the queues are stuck with the message "Screen output without connection to user", and we are recieving an ABAP dump as "DYNPRO_SEND_IN_BACKGROUND" in the CRM system. Is anybody aware of such problem ?Please suggest. -Nishik
-
How to configure rules in J2EE application
Please tell me how to configure rules in J2EE application. Configure rules in the sense before a page gets loaded a set of rules has to be fired automatically. A general idea how you would have been configured set of rules using java classes. If any
-
Photoshop Elements 10, Organizer funktioniert nicht mehr
Beim Einschalten von Adobe Photoshop Elements 10, Organizer erscheint ein Fenster mit dem Hinweis " Elements 10 Organizer funktioniert nicht mehr, es wird nach einer Lösung für das Problem gesucht". Darauf folgt: "Das Programm wird auf Grund eines Pr