How do I create an infinite drawing canvas in a ScrollPane?

I wanted to figure this out on my own, but it is time to ask for help. I've tried too many different things. The closest I've come to the behaviour I want is with this code:
final BorderPane root = new BorderPane();
final Pane canvasWrapper = new Pane();
canvasWrapper.setPrefSize(800, 500);
canvasWrapper.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
canvasWrapper.setStyle("-fx-background-color: lightgray; -fx-border-color: green; -fx-border-width: 2px;");
final Group canvas = new Group();
canvasWrapper.getChildren().add(canvas);
final ScrollPane scroll = new ScrollPane();
scroll.setContent(canvasWrapper);
root.setCenter(scroll);
// event code for adding circles and lines to the canvas
I want the ScrollPane to be filled with the Pane, so it can catch events for drawing. When the stage is resized, the ScrollPane is resized too. This the result of the BorderPane. What I want is to expand the window and have canvasWrapper expand to fill the entire ScrollPane viewport. When the stage is made smaller the ScrollPane shrinks, but I want the canvasWrapper to retain its size. The idea is the drawing canvas can only grow. When it gets too large for the current stage/ScrollPane size, the scrollpane can be used to navigate around the canvas.
I tried using
scroll.setFitToHeight(true);
scroll.setFitToWidth(true);
but this causes the Pane to be made smaller when the viewport is made smaller.

I figured it out!
Use
scroll.setFitToHeight(true);
scroll.setFitToWidth(true);
to resize the Pane as the view port changes.
Save the canvas' size as the Pane's size.
canvas.layoutBoundsProperty().addListener(new ChangeListener<Bounds>() {
            @Override
            public void changed(ObservableValue<? extends Bounds> ov, Bounds t, Bounds t1) {
                canvasWrapper.setMinSize(t1.getMaxX(), t1.getMaxY());
This forces the Pane to always be as large as the group is.
Missed a piece of code - jrguenther

Similar Messages

  • How do I create a gallery wrapped canvas image from my photo?

    I take portrait photo's, what I want to ask is how do I turn them into an image for my website that looks like the photo is wrapped around a canvas frame, I have seen loads of tutorials that create a cube effect, but I want it to look like its on a gallery wrapped canvas.
    I would really appreciate some ones help with this
    simon

    Thank you for your reply John
    To be honest I dont know, I think the latter
    If you view anyones website that sells canvas prints they have the canvas image where you can see 3 sides of the canvas and the photo wrapped around it, i want to create that image with my own photo's in photoshop (if thats possible) I am new to photoshop and dont really know to much at the moment
    simon

  • How can I create an infinitely refilling draggable item in Cocoa-Applescript, Xcode?

    It's hard to explain. The only example I can give it how you can infinately drag buttons from Xcode Editor into a window, except instead of a button, I need a custom view, and instead of a window, I need a verticle list. How can I do this using AppleScript-ObjC, in Xcode?

    NSTableView (or just NSScrollView) can be used, but you need to define what you are dragging - see Drag and Drop Programming Topics.

  • Can you change the canvas size in AI CC . If so how? Not the artboard but the canvas behind it. I have a large cad drawing.

    Can you change the canvas size in AI CC . If so how? Not the artboard but the canvas behind it. I have a large cad drawing.

    Vandushia,
    The Workspace size is fixed, 16,384 points.
    I am afraid you will have to work in a suitable scale, which could be 1:2, 1:4, 1:10, or whatever is most convenient.

  • Hi, somebody knows how to edit a file that I created in corel draw 11 and I need to edit like PDF!!!! is so simple and nobody knows howwwwwwwwwwww!!!!

    Hi, somebody knows how to edit a file that I created in corel draw 11 and I need to edit like PDF!!!! is so simple and nobody knows howwwwwwwwwwww!!!!

    See your other thread.

  • How can I create a drawing like the one pictured from a photo?

    How can I create a drawing like the one pictured from a photo?

    OK, you are getting closer. Now, use your result, and place a Layer above that. Use the Pen Tool to create the "pen strokes" basically tracing over your background image. Then, when you have created each Path (or Sub-Path), choose Stroke Path, with probably the Pencil Tool and a Brush size that is small enough.
    Not sure which versions of PS these are good for, but here are some plug-ins, that might be helpful.
    AKVIS Sketch
    EdgeLine
    Sketch Effects
    Sketch Master
    I see that one of my old favorites, Flaming Pear's India Ink is not around any more.
    Good luck,
    Hunt

  • How to create an infinite loop that cannot be cancelled?

    Hi , im new around java and i need a program that keeps on repeating after each each input/uses(generally meant for different user) and cannot either stop using "Cancel" or "x" while stopping only using the "stop" button
    I got a few lines of codes that look like this : String arg = "";
    do{
    JOptionPane.showInputDialog("hi");
    }while ( arg != "y" || arg!= "Y");
    and it cannot be stop with both cancel and"x"(which i wanted)
    but when i used this logic with
    Valid validUserInput = new Valid();
    do {
    userInput = validUserInput.validUserInput(a);
    switch(userInput){
    case 1 : validUserInput.optionOne(b);break;
    case 2 : validUserInput.optionTwo(c);break;
    case 3 : validUserInput.optionThree(d,e);break;
    default : validUserInput.validUserInput(f);
    }while(looping != "" || looping != " ");
    it does not really work(while it will keep looping, it can be easily stop by pressing cancelled or "x")
    So is there any logic or method that can prevent the program from being stop?
    Thankyou!

    elricscript wrote:
    "That is helpful. It gives him a direction where he can focus his research. Namely, 'how to run a program in kiosk mode' rather than 'how to create an infinite loop that cannot be cancelled.'"
    No... He already mentioned he wants to "e.g Interactive kiosk", so saying "properly kiosk it" isn't adding any new information. Rather it's just giving the person a dead point of: you're doing it wrong. Pointing out someone is wrong is not a positive enlightenment. Pointing someone in the right direction is more productive.
    >"That is helpful. It gives him a direction where he can focus his research. Namely, 'how to run a program in kiosk mode' rather than 'how to create an infinite loop that cannot be cancelled.'"
    No... He already mentioned he wants to "e.g Interactive kiosk", so saying "properly kiosk it" isn't adding any new information.
    Yes it is. He asked how to do it using some Swing trickery, and I said it won't work. Which is true. The OP didn't already know that, clearly, hence the question. Now he does. That's pretty much new information if you ask me.
    Rather it's just giving the person a dead point of: you're doing it wrong.Right. He is. However, the problem is now no longer related to Java, and not something I can help him with. You should try that: not answering questions you don't know the answer to. It's actually more helpful than posting misleading, wrong answers.
    Pointing out someone is wrong is not a positive enlightenment. I'm giving basic technical help, not yoga lessons.
    Pointing someone in the right direction is more productive.As already stated, I am as ignorant of how to make a Java application into a kiosk app as the OP is. What value can I add in light of that information? I began by answering a question that was not stated to be about kiosks. Once the question moved outside of my area of knowledge, I stopped trying to answer.
    I notice you're not giving him any help, being more interested in admonishing others as you are.

  • How can i creat several rectangles with one draw rect.vi

    how can i creat several rectangles with one draw rect.vi? thanks
    Solved!
    Go to Solution.

    You can call it in a for loop, with an array of the rectangle coordinates you want to draw. Is this what you mean?
    CLA, LabVIEW Versions 2010-2013
    Attachments:
    rectangle.png ‏11 KB

  • Can I add Any Layer on drawing canvas  ? if yes, How  ?

    Hi,
    I am developing a paint application in java JApplet. And I am drawing something like rectangle, free hand, oval, circle on canvas. I want to add Layer, which gives me seperate layer to work without erasing previous. I just read about LayeredPane and GlassPane. Which is suitable for using drawing. If it is layeredPane. then please tell me how to add single layer at single action performing like when I want to press pencil button then the layer will add. And when i want to press rectangle then second layer will add. And if it is GlassPane then how can i use it. I have used Glasspane. It making all buttons disabled. I just want to use it within drawing canvas. Please help me.....
    Thanks in advance
    Manveer

    Hello,
    I have read all documentation of JLayeredPane. Now I want to use it. Firstly I want to tell you that I have used a separate private class that is extending Panel. Then I have used double buffering for drawing anything on it. And after this I have added this class on JApplet by using getContentPane(). Can i add this canvas as layer, which contains images or drawing. Now what i want that When i have draw some thing on drawing canvas. And again want to draw something on canvas. at that time the canvas will add a layer which is a panel with setOpaque(false). which is totally transparent. And after set layer on canvas. the previous drawing remain same not be wash out or lost. And I can see the previous drawing after set layer. Please tell me how to do this. If you have any simple example or any advice for doing right thing. please tell me or send me.

  • How do i create infinite scroll on photo gallery

    I want to create an infinite scroll like on tumblr like this website ( Lookbook Theme )

    If the pictures are in your Camera Roll album, just tap the picture to bring up the menu and then tap the trash can.
    If the pictures are in your Photo Library album, you have to remove the pictures from the folder on your computer that you're syncing your iPhone to, then re-sync the iPhone.

  • How to save or save a drawing in a PNG or any Image file format ?

    Hi,
    I am working on a signature capturing application using J2ME MIDP 2.0 for Palm Treo 750 with Windows Mobile 6.0
    I am taking signatures as a drawing on a CustomItem.
    Now, i want to send it to a php script running on Apache server to save this signature as a PNG, jpeg or any image file at server end.
    or how can i save this drawing on my local file system as a png or any other type of image file.
    Plz help if anybody knows the right way....
    Thanks.

    Hi Hithayath,
    Thnx for the reply.
    Actually, i hv no problem in storing a data locally or sending it on a web server. The problem in related with the formats.
    I mean, how can we create a png or jpg file using the raw bytes of an image drawn on a canvas or CustomItem.. ?
    We can get the integer array of RGB points using getRGB() method of image object. Now, if i will write this data after converting to binary in a file then that file
    will show a message like "Preview not available". It means the format is not recognized.
    So, my question is how can we convert this raw data in a png or jpg format so it can be displayed on a web page or stored in a png or jpg file..?
    I think now u can better understand the problem.
    Waiting for the reply....
    Thanks. :)

  • How can I create and organize a symbol to be integrated into Illustrator's stock symbols?

    Hello,
    I am trying to create a series of symbols for maps (north arrows, scale bars, etc.) and then save them in Illustrator's "stock" symbol libraries - such as "maps".  The goal is that whenever I create a new Illustrator file, I can immediately grab these newly created symbols without having to open another file and copy the desired linework from the other file (just trying to be more organized and efficient).
    I am at a loss. I understand how to pull them into my drawing and break the link to modify.  I also have gone as far as to make a custom symbol and drag it into the "Symbols" dialog box - but it wont let me drag it into the "Maps" Dialog box.  And even if I dragged a symbol into the dialog box - is it automatically saved?  There are no instructions regarding how to save symbols the user creates.
    Please help!
    Happy Thanksgiving,

    Okay, that helped guys. Thank you.
    I was a little confused as to how it works.  Good to go now!

  • How do I create a 1d array that takes a single calculation and insert the result into the first row and then the next calculation the next time the loop passes that point and puts the results in thsecond row and so on until the loop is exited.

    The attached file is work inprogress, with some dummy data sp that I can test it out without having to connect to equipment.
    The second tab is the one that I am having the problem with. the output array from the replace element appears to be starting at the index position of 1 rather than 0 but that is ok it is still show that the new data is placed in incrementing element locations. However the main array that I am trying to build that is suppose to take each new calculation and place it in the next index(row) does not ap
    pear to be working or at least I am not getting any indication on the inidcator.
    Basically what I am attempting to do is is gather some pulses from adevice for a minute, place the results for a calculation, so that it displays then do the same again the next minute, but put these result in the next row and so on until the specifiied time has expired and the loop exits. I need to have all results displayed and keep building the array(display until, the end of the test)Eventually I will have to include a min max section that displays the min and max values calculated, but that should be easy with the min max function.Actually I thought this should have been easy but, I gues I can not see the forest through the trees. Can any one help to slear this up for me.
    Attachments:
    regulation_tester_7_loops.vi ‏244 KB

    I didn't really have time to dig in and understand your program in depth,
    but I have a few tips for you that might things a bit easier:
    - You use local variables excessively which really complicates things. Try
    not to use them and it will make your life easier.
    - If you flowchart the design (very similar to a dataflow diagram, keep in
    mind!) you want to gather data, calculate a value from that data, store the
    calculation in an array, and loop while the time is in a certain range. So
    theres really not much need for a sequence as long as you get rid of the
    local variables (sequences also complicate things)
    - You loop again if timepassed+1 is still less than some constant. Rather
    than messing with locals it seems so much easier to use a shiftregister (if
    absolutely necessary) or in this case base it upon the number of iterations
    of the loop. In this case it looks like "time passed" is the same thing as
    the number of loop iterations, but I didn't check closely. There's an i
    terminal in your whileloop to read for the number of iterations.
    - After having simplified your design by eliminating unnecessary sequence
    and local variables, you should be able to draw out the labview diagram.
    Don't try to use the "insert into array" vis since theres no need. Each
    iteration of your loop calculates a number which goes into the next position
    of the array right? Pass your result outside the loop, and enable indexing
    on the terminal so Labview automatically generates the array for you. If
    your calculation is a function of previous data, then use a shift register
    to keep previous values around.
    I wish you luck. Post again if you have any questions. Without a more
    detailed understanding of your task at hand it's kind of hard to post actual
    code suggestions for you.
    -joey
    "nelsons" wrote in message
    news:[email protected]...
    > how do I create a 1d array that takes a single calculation and insert
    > the result into the first row and then the next calculation the next
    > time the loop passes that point and puts the results in thsecond row
    > and so on until the loop is exited.
    >
    > The attached file is work inprogress, with some dummy data sp that I
    > can test it out without having to connect to equipment.
    > The second tab is the one that I am having the problem with. the
    > output array from the replace element appears to be starting at the
    > index position of 1 rather than 0 but that is ok it is still show that
    > the new data is placed in incrementing element locations. However the
    > main array that I am trying to build that is suppose to take each new
    > calculation and place it in the next index(row) does not appear to be
    > working or at least I am not getting any indication on the inidcator.
    >
    > Basically what I am attempting to do is is gather some pulses from
    > adevice for a minute, place the results for a calculation, so that it
    > displays then do the same again the next minute, but put these result
    > in the next row and so on until the specifiied time has expired and
    > the loop exits. I need to have all results displayed and keep building
    > the array(display until, the end of the test)Eventually I will have to
    > include a min max section that displays the min and max values
    > calculated, but that should be easy with the min max function.Actually
    > I thought this should have been easy but, I gues I can not see the
    > forest through the trees. Can any one help to slear this up for me.

  • How can I create a java.awt.Image from ...

    Hi all,
    How can I create a java.awt.Image from a drawing on a JPanel?
    Thanks.

    JPanel p;
    BufferedImage image =
        new BufferedImage(p.getWidth(), p.getHeight, BufferedImage.TYPE_INT_RGB);
    Graphics2D g = image.createGraphics();
    p.paint(g);
    g.dispose();

  • How can I remove all the drawing canvases from a Word file?

    Hi,
    There are many drawing canvases in the document, which were created by pressing 'edit' on embedded EMF files.
    I would like to replace the embedded figures with object references, so I searched for a way to delete all the drawing canvases but couldn't find the result.
    Is there a macro that will delete all the drawing canvases in the document? Or, is the drawing canvas defined as an object type at all?
    Thanks in advance.

    Hi,
    According to your description, do you want to change the shapes or other content's figures with object references of the drawing canvases in Word?
    If you need to use a macro, I recommend you post the question to MDSN forum for Word:
    http://social.msdn.microsoft.com/Forums/en-US/home?forum=worddev&filter=alltypes&sort=lastpostdesc
    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.
    George Zhao
    TechNet Community Support

Maybe you are looking for

  • How do I redownload mountain lion for a clean install on the same machine without purchasing again?

    I purchased mountain lion and upgraded my OS.  The system seems to still be having some issues and I'd like to do a clean install with the new OS.  How do I redownload mountain lion so that I can make a bootable disk and do my clean install?

  • RoboHelp HTML 8 Search problem

    I have a single (non-merged) RoboHelp 8 HTML project in which I cannot seem to get Search working correctly. I expected to see a box into which I can type a search term and a blank pane below the Contents/Index/Search/Glossary bar where search result

  • Making my 2nd BT line the main phone line

    Hi I've been trying to find a solution for this with no luck. Spoken to several BT engineers (all based abroad!) and no one seems to understand the issue, let alone help. A pointer in the right direction would be hugely appreciated! We have 2 lines c

  • Jump in data use after trip

    The strangest thing has happened twice on my family plan. Two people in my family went on trips out of the country. We got an international data plan, which all worked fine. But I thought it was safe to presume that while out of the country, none of

  • Cash or bank account should not go below zero

    hi friends, what are configuration required to set bank and cash account should not go below zero. and system should give an error message for the same.