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:
sunnymanman
sonudevgan wrote:
dear piz tell me how i can read integer from user my email id is [email protected]
foolish, foolish question
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 draw lines in FCPX ?
Hi there,
I would like to have a simple Effects that will draw lines in various shape such as circle, ellipse or rectangle. How do I do it ?
I need it because I want to have an effect that is drawing an ellipse over the text.
Any ideas ?
Thanksok... hmmm...
You can create control points for a line but you cannot animate the control points in FCPX. If you're okay with that, then here are the basics:
Create a new top level group. Name it OSCs.
In the Inspector, select the group and in the Group tab of the inspector, select Fixed Resolution. (It should already be set to 2D - if not - set 2D)
In the Properties > Timing pane, set the length (Duration) of the group to at least as long as your project. (this step is not important in Motion but absolutely necessary for FCPX!)
With the new group selected, add the filters you will use as control points. In general, every starts with Filters > Distortion > Poke. You will need two of them. For each Poke filter, select Publish OSC in the inspector. (I recommend renaming each filter - startOSC, endOSC for example.)
Create another new group.
Go into the Library > Content and search for Crosshair -- there's three of them, use Crosshair-Minute (they're the smallest ones.) Add two of them. (It's not necessary that they're in their own group -- just more convenient.) Rename the crosshairs: keeping with the OSCs, I recommend start and end, for example.
Draw a Line.
To the shape (line), add two Behaviors > Shape > Track Points.
Rename the Track Points: Start and End.
In the Behaviors inspector for the Track Points, drag the start Crosshair image into the Source well of the Start track points and the end Crosshair image into the End Track Points. The behavior parameters will change and you'll see a bunch of new stuff. Down at the bottom, you'll see Track 1 and Track 2 — leave one checked for one of the behaviors and the other one checked for the second behavior (that's 1 track 1 and 1 track 2.) You'll also see that the Transform is set to Mimic Source. What you need to do is click the reset button on the Checked Track of each behavior and THEN change the Transform to Attach to Source. Once you do that, the line ends will snap to crosshair images (use Properties Transform X to move the crosshairs apart temporarily.)
Next step:
Select the start crosshair and in the Inspector > Properties, dial down the Position to reveal the XYZ parameters. Right click on the X and select Add Parameter Behavior > Link. Repeat this step for the Y parameter (you cannot link Position.All for this step.)
In the Behaviors inspector, for the start crosshair:
For the Source Object, drag the OSCs group into the well.
for the X parameter
For the Source Parameter, set Filters.startOSC.Center.X for the Position.X
and set Filters.startOSC.Center.Y for the Position.Y
You will notice the line end disappear off the screen. This is normal. To correct this, at the bottom of each behavior, set the X (or Y) offset to -0.5.
Repeat for the end crosshair.
You can turn off the crosshairs (uncheck the layers.)
To test your OSCs, select *both* startOSC and endOSC (command select each layer) -- both Poke OSCs will appear and you can drag them around the canvas. The line should follow as you would expect if you've set everything up correctly.
Publish the template.
A couple of explanations:
2D fixed resolution for the OSC group: Groups in Motion that are not fixed resolution can dynamically change their boundaries. There are no fixed points of reference for Motion to calulate. If you forget to set Fixed Resolution, you can repair the condition by setting the Fixed Resolution option and then go into the Filters pane and reset the Center parameters for each Poke OSC.
Offsets of -0.5: All resolutions in the Canvas are calculated by the resolution of the X and Y dimensions of the project times the fractional position of objects (from 0.0 on the left side for X and on the bottom for Y — to 1.0 on the right side for X and on the top for Y.) The center of the canvas is 0, 0 in pixels of whatever the resolution is. To adjust the fractional position used by the OSCs (and others) to the center pixel, the value needs to be moved by 1/2 of that distance.
Clear as mud? Once you've done it a few times, it will all become second nature.
One more thing: you can publish curves... complex ones. But they have to be B-spline (you track all the points in a similar manner outlined above) and not Bezier. There's no way to control the handles for bezier curves. -
How to insert line with values in ALV (CL_GUI_ALV_GRID)?
Hi,
Does anyone know how to get control of new line inserted in ALV (I am using class CL_GUI_ALV_GRID) before the new line is shown to the user. What I want the user to see is not a completely blank line, but a new line with certain fields filled with data.
I have tried with ALL events in CL_GUI_ALV_GRID but without any luck. If I create my own user command and insert it in the alv menu I get control, but not with the standards. Why?
Please help
Kind regards - Keld GregersenHi,
I created a nice work around...
CLASS lcl_event_handler DEFINITION.
handle_toolbar
FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object e_interactive,
handle_user_command
FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm.
ENDCLASS. "lcl_event_handler DEFINITION
CLASS lcl_event_handler IMPLEMENTATION.
METHOD handle_toolbar.
DATA:
l_toolbar TYPE stb_button.
Here I replace SAP standard functions with own functions
READ TABLE e_object->mt_toolbar INTO l_toolbar
WITH KEY function = '&LOCAL&APPEND'.
IF sy-subrc = 0.
l_toolbar-function = 'OWN_APPEND'.
MODIFY e_object->mt_toolbar FROM l_toolbar INDEX sy-tabix.
ENDIF.
READ TABLE e_object->mt_toolbar INTO l_toolbar
WITH KEY function = '&LOCAL©_ROW'.
IF sy-subrc = 0.
l_toolbar-function = 'OWN_COPY_ROW'.
MODIFY e_object->mt_toolbar FROM l_toolbar INDEX sy-tabix.
ENDIF.
ENDMETHOD. "handle_toolbar
METHOD handle_user_command.
CASE e_ucomm.
WHEN 'OWN_APPEND'.
CALL METHOD ref_alv->check_changed_data
IMPORTING
e_valid =
CHANGING
c_refresh = 'X'
CREATE YOUR OWN CODE HERE
CALL METHOD ref_alv->refresh_table_display
EXPORTING
is_stable = 'X'
i_soft_refresh =
EXCEPTIONS
finished = 1
others = 2
ENDMETHOD. "handle_user_command
ENDCLASS. "lcl_event_handler IMPLEMENTATION
Kind regards
Keld Gregersen -
Hi everyone,
Who have a good way to draw lines on SAP form?
I created a Wizard form, and use Rectangle (Height=0) as the two lines between title and bottom button, but I met a problem, when show another form which cover the line, after close this form, some part of lines disappear, I have tried using SAP form refresh, it still can not restore showing line completely, who have good way to workaround the problem or give me another way to draw line.
Thanks in advance!
KathyThe only way I found to get a form looking really close to a standard B1 Wizard form is to use bitmaps. I use 3 - one each for the top, bottom and left hand side. The bitmaps include the line drawing and appropriate pictures/background colours. I normally define these in the XML used to create the form as in the following example:-
<item uid="PTOP" type="117" left="0" width="566" top="0" height="80" visible="1" enabled="1" from_pane="0" to_pane="0">
<AutoManagedAttribute/>
<specific picture="AZU_SPC_WIZ_TOP2.bmp">
<databind databound="0" table="" alias=""/>
</specific>
</item>
<item uid="PBOT" type="117" left="0" width="566" top="336" height="40" visible="1" enabled="1" from_pane="0" to_pane="0">
<AutoManagedAttribute/>
<specific picture="AZU_SPC_WIZ_BOT.bmp">
<databind databound="0" table="" alias=""/>
</specific>
</item>
<item uid="PLEFT" type="117" left="0" width="100" top="0" height="336" visible="1" enabled="1" from_pane="1" to_pane="1">
<AutoManagedAttribute/>
<specific picture="AZU_SPC_WIZ9.bmp">
<databind databound="0" table="" alias=""/>
</specific>
</item>
John. -
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). -
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 );
} -
HELP!!! Begginer working with a Swing Applet. DON'T KNOW HOW TO DRAW LINE
Hi! I've been trying to draw a line in an applet and I can't. The thing is I'm using the tutorial to create the applet, so it comes with the standart methos and the standalone. I'm not sure if the problem is becausse I need to include in it a paint method or something.
What I'm trying to do is to connect the to blocks (they really are jButtons), with an arrow. Thanks!!!!!!!!!
Here's my code so far...// Copyright (c) 2000
package package14;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import oracle.jdeveloper.layout.*;
* Applet
* <P>
* @author Ana M Yanes Benatuil
public class Appletboxes extends JApplet {
boolean isStandalone = false;
XYLayout xYLayout1 = new XYLayout();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
* Constructs a new instance.
* getParameter
* @param key
* @param def
* @return java.lang.String
public String getParameter(String key, String def) {
if (isStandalone) {
return System.getProperty(key, def);
if (getParameter(key) != null) {
return getParameter(key);
return def;
public Appletboxes() {
* Initializes the state of this instance.
* init
public void init() {
try {
jbInit();
catch (Exception e) {
e.printStackTrace();
private void jbInit() throws Exception {
this.getContentPane().setLayout(xYLayout1);
this.setSize(new Dimension(836, 545));
jButton1.setText("jButton1");
jButton2.setText("jButton2");
jButton2.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
public void mouseDragged(MouseEvent e) {
jButton2_mouseDragged(e);
jButton1.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
public void mouseDragged(MouseEvent e) {
jButton1_mouseDragged(e);
this.getContentPane().add(jButton1, new XYConstraints(137, 120, 96, 45));
this.getContentPane().add(jButton2, new XYConstraints(452, 118, 96, 49));
* start
public void start() {
* stop
public void stop() {
* destroy
public void destroy() {
* getAppletInfo
* @return java.lang.String
public String getAppletInfo() {
return "Applet Information";
* getParameterInfo
* @return java.lang.String[][]
public String[][] getParameterInfo() {
return null;
* main
* @param args
public static void main(String[] args) {
Appletboxes applet = new Appletboxes();
applet.isStandalone = true;
JFrame frame = new JFrame();
frame.setTitle("Applet Frame");
frame.getContentPane().add(applet, BorderLayout.CENTER);
applet.init();
applet.start();
frame.setSize(400, 420);
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
frame.setLocation((d.width - frame.getSize().width) / 2, (d.height - frame.getSize().height) / 2);
frame.setVisible(true);
frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } });
static {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
catch(Exception e) {
e.printStackTrace();
void jButton1_mouseDragged(MouseEvent e) {
jButton1.setLocation(e.getX() + jButton1.getX() , e.getY() + jButton1.getY());
void jButton2_mouseDragged(MouseEvent e) {
jButton2.setLocation(e.getX() + jButton2.getX() , e.getY() + jButton2.getY());The other thing is that the boxes can be dragged and dropped, so the lines would have to be moved too (if they're related to the moved blocks)
-
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 draw line to connect components dynamically??
Dear Friends:
I have following code is for drag/drop label, I hope to draw straight line to connect any TWO or more labels within this panel,
[1]. keep all connected line
[2]. can draw dynamically,
I search quite a while with google, still very confused,
Can any guru throw aome light how to do
[1]. code 1:
package swing.dnd;
import java.awt.*;
import javax.swing.*;
public class TestDragComponent extends JFrame {
public TestDragComponent() {
super("Test");
Container c = getContentPane();
c.setLayout(new GridLayout(1,2));
c.add(new MoveableComponentsContainer());
c.add(new MoveableComponentsContainer());
pack();
setVisible(true);
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
catch (Exception ex) {
System.out.println(ex);
new TestDragComponent();
[2]. Code 2:
package swing.dnd;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.*;
import java.awt.dnd.*;
import java.awt.datatransfer.*;
import java.awt.image.*;
import java.awt.dnd.DragSource;
import java.awt.dnd.DropTarget;
public class MoveableComponentsContainer extends JPanel {
public DragSource dragSource;
public DropTarget dropTarget;
private static BufferedImage buffImage = null; //buff image
private static Point cursorPoint = new Point();
public MoveableComponentsContainer() {
setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED, Color.white, Color.gray));
setLayout(null);
dragSource = new DragSource();
ComponentDragSourceListener tdsl = new ComponentDragSourceListener();
dragSource.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY_OR_MOVE, new ComponentDragGestureListener(tdsl));
ComponentDropTargetListener tdtl = new ComponentDropTargetListener();
dropTarget = new DropTarget(this, DnDConstants.ACTION_MOVE, tdtl);
setPreferredSize(new Dimension(400,400));
addMoveableComponents();
private void addMoveableComponents() {
MoveableLabel lab = new MoveableLabel("label 1");
add(lab);
lab.setLocation(10,10);
lab = new MoveableLabel("label 2");
add(lab);
lab.setLocation(40,40);
lab = new MoveableLabel("label 3");
add(lab);
lab.setLocation(70,70);
lab = new MoveableLabel("label 4");
add(lab);
lab.setLocation(100,100);
final class ComponentDragSourceListener implements DragSourceListener {
public void dragDropEnd(DragSourceDropEvent dsde) {
public void dragEnter(DragSourceDragEvent dsde) {
int action = dsde.getDropAction();
if (action == DnDConstants.ACTION_MOVE) {
dsde.getDragSourceContext().setCursor(DragSource.DefaultMoveDrop);
else {
dsde.getDragSourceContext().setCursor(DragSource.DefaultMoveNoDrop);
public void dragOver(DragSourceDragEvent dsde) {
int action = dsde.getDropAction();
if (action == DnDConstants.ACTION_MOVE) {
dsde.getDragSourceContext().setCursor(DragSource.DefaultMoveDrop);
else {
dsde.getDragSourceContext().setCursor(DragSource.DefaultMoveNoDrop);
public void dropActionChanged(DragSourceDragEvent dsde) {
int action = dsde.getDropAction();
if (action == DnDConstants.ACTION_MOVE) {
dsde.getDragSourceContext().setCursor(DragSource.DefaultMoveDrop);
else {
dsde.getDragSourceContext().setCursor(DragSource.DefaultMoveNoDrop);
public void dragExit(DragSourceEvent dse) {
dse.getDragSourceContext().setCursor(DragSource.DefaultMoveNoDrop);
final class ComponentDragGestureListener implements DragGestureListener {
ComponentDragSourceListener tdsl;
public ComponentDragGestureListener(ComponentDragSourceListener tdsl) {
this.tdsl = tdsl;
public void dragGestureRecognized(DragGestureEvent dge) {
Component comp = getComponentAt(dge.getDragOrigin());
if (comp != null && comp != MoveableComponentsContainer.this) {
cursorPoint.setLocation(SwingUtilities.convertPoint(MoveableComponentsContainer.this, dge.getDragOrigin(), comp));
buffImage = new BufferedImage(comp.getWidth(), comp.getHeight(), java.awt.image.BufferedImage.TYPE_INT_ARGB_PRE);//buffered image reference passing the label's ht and width
Graphics2D graphics = buffImage.createGraphics();//creating the graphics for buffered image
graphics.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f)); //Sets the Composite for the Graphics2D context
boolean opacity = ((JComponent)comp).isOpaque();
if (opacity) {
((JComponent)comp).setOpaque(false);
comp.paint(graphics); //painting the graphics to label
if (opacity) {
((JComponent)comp).setOpaque(true);
graphics.dispose();
remove(comp);
dragSource.startDrag(dge, DragSource.DefaultMoveDrop , buffImage, cursorPoint, new TransferableComponent(comp), tdsl);
revalidate();
repaint();
final class ComponentDropTargetListener implements DropTargetListener {
private Rectangle rect2D = new Rectangle();
Insets insets;
public void dragEnter(DropTargetDragEvent dtde) {
Point pt = dtde.getLocation();
paintImmediately(rect2D.getBounds());
rect2D.setRect((int) (pt.getX()-cursorPoint.getX()),(int) (pt.getY()-cursorPoint.getY()),buffImage.getWidth(),buffImage.getHeight());
((Graphics2D) getGraphics()).drawImage(buffImage,(int) (pt.getX()-cursorPoint.getX()),(int) (pt.getY()-cursorPoint.getY()),MoveableComponentsContainer.this);
dtde.acceptDrag(dtde.getDropAction());
public void dragExit(DropTargetEvent dte) {
paintImmediately(rect2D.getBounds());
public void dragOver(DropTargetDragEvent dtde) {
Point pt = dtde.getLocation();
paintImmediately(rect2D.getBounds());
rect2D.setRect((int) (pt.getX()-cursorPoint.getX()),(int) (pt.getY()-cursorPoint.getY()),buffImage.getWidth(),buffImage.getHeight());
((Graphics2D) getGraphics()).drawImage(buffImage,(int) (pt.getX()-cursorPoint.getX()),(int) (pt.getY()-cursorPoint.getY()),MoveableComponentsContainer.this);
dtde.acceptDrag(dtde.getDropAction());
public void dropActionChanged(DropTargetDragEvent dtde) {
Point pt = dtde.getLocation();
paintImmediately(rect2D.getBounds());
rect2D.setRect((int) (pt.getX()-cursorPoint.getX()),(int) (pt.getY()-cursorPoint.getY()),buffImage.getWidth(),buffImage.getHeight());
((Graphics2D) getGraphics()).drawImage(buffImage,(int) (pt.getX()-cursorPoint.getX()),(int) (pt.getY()-cursorPoint.getY()),MoveableComponentsContainer.this);
dtde.acceptDrag(dtde.getDropAction());
public void drop(DropTargetDropEvent dtde) {
try {
paintImmediately(rect2D.getBounds());
int action = dtde.getDropAction();
Transferable transferable = dtde.getTransferable();
if (transferable.isDataFlavorSupported(TransferableComponent.COMPONENT_FLAVOR)) {
Component comp = (Component) transferable.getTransferData(TransferableComponent.COMPONENT_FLAVOR);
Point location = dtde.getLocation();
if (comp == null) {
dtde.rejectDrop();
dtde.dropComplete(false);
revalidate();
repaint();
return;
else {
add(comp, 0);
comp.setLocation((int)(location.getX()-cursorPoint.getX()),(int)(location.getY()-cursorPoint.getY()));
dtde.dropComplete(true);
revalidate();
repaint();
return;
else {
dtde.rejectDrop();
dtde.dropComplete(false);
return;
catch (Exception e) {
System.out.println(e);
dtde.rejectDrop();
dtde.dropComplete(false);
Thanks so much for any help.
Reagrds
sunnyCraig Wood's code here might do what you want
http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=2&t=015259 -
How to draw line of best fit?
Hey all,
I am trying to draw a line of best fit with the scattered points being displayed as well. I have attached my VI below and tried all sorts of methods,
but to no avail. I am aware that there is a 'liner fit.vi' which I tried, but it did not give me what I wanted. In fact the line wasn't best fit at all.
I hope someone could help me as I'm new to LabVIEW.
Thanks in advance!
Cheers,
Ruben
Attachments:
Weibull LabVIEW Plot_Valve Spring.vi 15 KBHi Ruben
The Linear Fit.vi should provide the results you require. Check the attachment for an edited version of your code. Does this solve your problem? You can check the help file for advice on using different fitting techniques, setting tolerances and weightings.
Regards,
Peter D
Attachments:
EDIT_Weibull LabVIEW Plot_Valve Spring.vi 23 KB -
How to draw line art on a panel?
I've spent a bit of time trying to figure out where to start, and come up with nothing, so.....
..... In CS6 I'm looking to put the equivalent of a C# picturebox onto a plugin panel to act as a thumbnail of sorts. Within the picturebox the plugin would draw some lineart that would represent some properties of the original artwork that are of interest to the user.
Is there a specific SDK suite that comes anywhere close to giving me some of that functionality?http://www.java2s.com/ExampleCode/2D-Graphics/Line.htm
-
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 -
How to draw faster with brush tools in illustrator CS 5
If I draw with brush pen in Illustrator CS 5 the performance become slow, how to overcome this problem?
Thanks Monica and Steve for the answer,
I am using Machintosh Imac 21,5 inch, late 2012, processor 2,7 Ghz intel core i5, memory 8 Gb, 1600 MHz DDR3, software os x 10.8.5, and software Illustrator CS 5, version 15.1.0., paper size A3, raster effect 300 ppi
I am using tool brush artistic chalkcharcoal pencil, when i was made cross hatching to create tone in the begginning was fine, the brush appereance is real time, sooner after soo many rendering the brush getting slow the apperance unrealtime
maybe because too many path in one layer ( brush render layer). i have try too group that layer, or make into symbol , it doesn't help still slow.
Anybody can help me?
Maybe you are looking for
-
How can I edit ALL photos in an album at once instead of one at a time?
I have approximately 300 new photos in an album and would like to rename all of them 'Rome Vacation'. Is there a way to change all of the titles at once, or do I have to change them one at a time? Thanks, Paul
-
Hi all, I am a newbie to adobe livecycle process. I am trying to prepopulate the data like the users info when the form is originated in the workspace. I did use the samples example for form render service but added to variables called first and last
-
Java DC not deployed with WebDynPro DC
Hi, I've been testing the DC functionality and I'm trying to create the following: 1) WebDynPro DC (DCA) 2) Java DC (DCB) DCB has code for reading data from a database table (three classes, one is set as a public part). This code is functioning ok in
-
What is the model of the WWAN Module in a HP TX1000Z Tablet PC?
I recently have acquired a HP TX1000Z Tablet PC, which features a WWAN module. I was wondering if someone could tell me the exact device brand and model (as in, Sierra Wireless MCXXXX (XXXX are numbers)), because I looked in the repair guide for the
-
Classpath setting "unable to access jarfile"
Hi when i run $java -jar batik-squiggle.jar the error message on screen is "unable to acces jarfile batik-squiggle.jar" and the path of the jar file is edited with the $CLASSPATH variable in the ~/.bash_profile if i execute $java -jar /usr/share/bati