JScrollPane Clip Bounds Incorrect

I have a JScrollPane that contains a JLayeredPane. The JLayeredPane contains a variable set of objects (custom JComponents). These custom components can change their size based on user action.
My problem is that the clipping rectangle of the graphics context in the paint method of the JLayeredPane is incorrect. It only represents the initial size of the screen. For example, my initial application frame is 200x200. The JLayeredPane's size is 400x400. This (properly) results in horizontal and vertical scroll bars. The problem is that when scrolling, the non-visible portion of the component never gets repainted. In looking at the clip bounds for the graphics, it shows that it is repainting only the initially visible portion of the custom object.
This problem disappears if I first resize the main frame to get rid of the scroll bars. Once this is done, I can set the size of the window back to what it previously was and scroll without any painting problems. Does something magical happen when the scroll bar disappears? I've tried a number of variations on doLayout(), revalidate(), repaint(), but with no luck.
Thanks for the input,
Tom

I've been able to pinpoint (and fix) the problem of the clipping bounds not being properly set. My JScrollPane contained a JLayeredPane subclass that had overridden the getSize() and getPreferredSize() methods. The size of my JLayeredPane changes based on user action. Both methods were always returning the same size (though that size was changing).
I'm not exactly why this fixes things, but I changed my getPreferredSize() method to return a dimension exactly 1 pixel greater in both width and height than the dimension returned by getSize(). After doing this, everything paints properly. Does anyone know why this would work?
I wonder if the JScrollPane's layout manager sees that the sizes are different and makes sure things are updated properly. I tried making the preferred size smaller than the getSize(), but I lost my scrollbars entirely.
Tom

Similar Messages

  • Animation Clip bounds?

    Does anyone know if there is a way to clip a Node so that when it has a translate or scale applied it doesn't expand past the bounds of its parent container?
    In the following code, the Label flies all around the place, which is pretty cool. But I want it to be clipped to the container it is in (i.e. 'animationArea') and not draw over the top of all the other components in my scene. When the node is outside of the animationArea it ideally would be clipped so that half the node is not drawn, etc. I want to achieve a slide-out effect.
    public class TestApp extends Application
        public static void main(String[] args) throws Exception
            launch(args);
        public void start(Stage stage) throws Exception
            BorderPane contentPane = new BorderPane();
            HBox top = new HBox();
            top.getChildren().add(new Label("Top Area"));
            top.setStyle("-fx-background-color: blue");
            top.setPrefHeight(100);
            contentPane.setTop(top);
            HBox bottom = new HBox();
            bottom.getChildren().add(new Label("Green Area"));
            bottom.setStyle("-fx-background-color: green");
            bottom.setPrefHeight(100);
            contentPane.setBottom(bottom);
            HBox left = new HBox();
            left.getChildren().add(new Label("Green Area"));
            left.setStyle("-fx-background-color: yellow");
            left.setPrefWidth(100);
            contentPane.setLeft(left);
            HBox right = new HBox();
            right.getChildren().add(new Label("Right Area"));
            right.setStyle("-fx-background-color: red");
            right.setPrefWidth(100);
            contentPane.setRight(right);
            FlowPane animationArea = new FlowPane();
            Label label = new Label("Look at me, I'm flying!");
            label.setStyle("-fx-background-color: #ffd; -fx-background-radius: 3; -fx-border-color: gray; -fx-background-radius: 3; ");
            animationArea.getChildren().add(label);
            contentPane.setCenter(animationArea);
            Scene scene = new Scene(contentPane, 800, 600);
            scene.getStylesheets().add("styles.css");
            stage.setScene(scene);
            stage.show();
            TranslateTransition animation = new TranslateTransition(Duration.millis(2000), label);
            animation.setFromX(-100);
            animation.setToX(800);
            animation.setFromY(-400);
            animation.setToY(400);
            animation.setAutoReverse(true);
            animation.setCycleCount(Animation.INDEFINITE);
            animation.playFromStart();
    }

    Thanks for the help guys, both very helpful as usual.
    I've had a go at doing it properly with the clip bounds but it is very painful to implement and I think I will give up for now and wait for the proper fix. The time I'll need to invest to get it working isn't worth it at this stage. The problem is that the calculations need to work of the translated/scaled bounds (i.e. boundsInParent) but when I apply a clip to the node it changes these boundsInParents so I'm constantly working with a moving target. I reckon if I spent enough time on it I would eventually hack something together but given its just for a funky animation I think I will wait for a fix from Amy. I'll just have to stick to fade in and fade out for my page transitions for now :)
    As an aside, Michael (but also jsmith), did you ever have a play around with that Browser stuff I linked to a little while back? I'm about to upload some reworks of the API based on some work I was doing for Richard and his devoxx demo (although in truth, he got a bit busy, so the code is still lacking any official input and he may have other ideas on what he would like to see in the official JFX version of a browser framework long term). I'm reasonably happy with how it's panned out though and I'm trying now to tie up the loose ends. If either of you guys (or anyone else who is confident with JFX and feeling brave) were interested in looking at it in its raw form and providing some early feedback and/or contributions, I'd be interested and appreciative. I probably don't want to use the forum too much for this though as it creates a lot of noise around design-discussions, which makes it harder for newbies to find the real answers they are after when they search.
    If you guys are interested at all, send me an email at my hotmail which is d a n j z minus the spaces and add the @ and the hotmail.com. That one gets spammed to death anyway, but if you contact me there, I will send you my real email.
    Cheers,
    zonski

  • Web clips displaying incorrectly or not loading

    I have two Web clips: one of some weather from Weather.com, and one that shows the daily image from APhotoADay.org. However, neither of them works properly. The weather Web clip simply does not attempt to load, while the photo Web clip loads but displays the photo incorrectly. Here's a cap to illustrate what I mean:
    Above is the weather Web clip, and below is the photo.
    Earlier today it looked less contrasty, like this:
    And here's the original image as it should appear:
    If I go create the Web clips again, they work temporarily before reverting to this state. The photo one also sometimes fails to load at all, though it usually does.
    This problem is new in the last few days and appears to be unrelated to software updates, since my Web clips worked normally for a few weeks after the OS update and I haven't updated anything else since then that I know of.
    Any idea what's going on or what I can do about it?

    One Solution to use combs in v7 you can find <br /><a href="http://www.adobeforums.com/cgi-bin/webx/.3bc06e11">here.</a> <br /><br /><br />Set your field to limit length max.chars 'x'. <br /><br />You can made it also per hand in the xml code, go to your field and...<br /><br /><field settings><br /><br /> <value><br /><br /><b>  &lt;text maxChars="3"/&gt; </b><br /><br /> </value><br /><br /></field><br /><br /><br />Then you have to edit the xml-source by hand, but its not so much work.<br /><br />Mark your field and go to the xml source, edit the bold parts.<br /><br /><field settings><br /><br /> <ui><br /><br />  <textedit><br /><br /><b>   <border hand="right"> </b>  <br /><br />   </border><br /><br /><b>   <comb/> </b><br /><br />  </textEdit><br /><br /> </ui><br /><br /></field><br /><br /><br />Should this sounds to confused, look into the <a href="http://home.freeuk.com/iamlazyworm/comb.pdf">comb.pdf</a> you can find in the link above. <br /><br />Greetings Matthias

  • Missing DVCPro HD device and clips play incorrectly

    I've tried everything in the book. Hvx200, 720/60 48khz. First, the device normally shows up upon launch but not anymore. Clips appear in log&transfer but play incorrectly. For a second its good and then deteriorates to audio drop and major lag. I tried copy and paste .mxf and .txt files to drive and that fixed the log&transfer playback issue but once converted into fcp same song and dance. I tried updating p2 driver and dvcprohd components codec update and still not gonna do it. Also, in audio/video settings, tried every single combination that would read the format. I think it's a conversion problem and I have know other idea as to how to fix this. ps. I've tried reinstalling fcp too and i'm downloading the latest update as I write.

    I'd reinstall FCP 5. That should put back anything that's missing.  It should work on top of the app that's there. But if things mess up, get the FCS Remover app from digitalrebellion.com (free), uninstall FCP, then install it again.

  • Video Clip Length incorrect

    I'm trying to figure this out, I've imported my video clip but for some reason, the video clip is 30 minutes long, but on the timeline the video is only 10 or so seconds long.  Basically, 10 seconds are making up a 30 minute video.  I've never seen this before, any ideas?

    I have had similar results, when using converted DV-AVI Type II files for my normally bullet-proof converter. Similar files from the same group and same CODEC, will Import fine into PrPro. Occasionally, I'll get a "rogue" file, where PrPro sees the Duration as totally wrong, though not with as much truncation, as you observe. I my situation, I have found that simply Importing these truncated files into PrElements and then doing an Export to the same exact format/CODEC, DV-AVI Type II, always fixes the problem. Why 1:100 files exhibits this problem is unknown to me. Why Importing into PE and then Exporting to the same exact spces. fixes it, is also unknown. G-Spot gives the same exact info on each the "before" and the "after," but PrPro sees the Duration incorrectly.
    I'm with Jeff in how you should handle this - Conversion. Actually, I'd go back a step and use another ripper, and one that allows for DV-AVI Type II w/ 48KHz 16-bit Audio, but that is just me. This could well save you some quality and another step. There are other DVD rippers, that are also freeware.
    Good luck,
    Hunt

  • Imported iMovie HD project clips have incorrect capture date - add-on info

    People converting their .dv files from the iMovie HD style into iMovie 09 style report some frustration at having to rename their clips to view them properly. For discussion, see:
    http://discussions.apple.com/thread.jspa?threadID=1344628
    Fortunately, within the thread, a kind soul has posted a solution - many thanks. This posting is an add-on to that thread, posted here because that thread is archived.
    Unfortunately, I could not understand the instructions fully, so I spent some time working out how to make it go, since the solution requires something beyond the usual drag-and-drop to work.
    *To Convert the Dates and Names of DV Files from iMovie HD to the Event-Date Format of iMovie 09*
    1. Download and Unzip the DVRecordingDate file. It produces a folder with four items: COPYING.txt, DVRecordingDate.class, README.txt and DVRecordingDate.java. None of these should be double clicked.
    2. Identify the folder that has your iMovie 6 .dv files. These files will be entirely renamed, so if they are used in any other projects, only work on a copy of them.
    3. Launch the program Terminal - it's in the Utilities folder of the Applications folder
    4. When you see a prompt ending in a $, type +cd /Users/yourname/Downloads/DVrecordingDate-1-1.0+,
    where /Users/yourname/Downloads/DVrecordingDate-1-1.0 is the folder containing the downloaded DVRecordingDate file. This will change the prompt that appears on every line, but it will still end with a $.
    (HINT: you can get the path name of this folder by selecting it in the Finder, and choosing copy. All you then need do is type cd in Terminal, and paste the rest in.)
    Now is when we rename the files - as stated elsewhere, the Finder creation date is NOT changed - it is only the file name that changes. However, this is enough for iMovie 09 to understand when the file was recorded, and where it should be stored within the events system.
    5. At the $ prompt, type +java DVRecordingDate -rename /Users/yourname/Movies/iMovie\ Events.localized/myholiday/Clip\ *.dv+, where +/Users/yourname/Movies/iMovie\ myholiday/+ is the name of the the folder that has your iMovie 6 .dv files. Again, this can be copied from the Finder, and pasted in after typing java DVRecordingDate -rename. The *.dv part os to ensure the program coverts all your files in the folder.
    A list appears:
    Renaming file(s) from, to:
    /Users/yourname/Movies/myholiday/Clip 01.dv clip-2003-08-31 20;37;41.dv
    /Users/yourname/Movies/myholiday/Clip 02.dv clip-2003-09-04 18;43;26.dv
    /Users/yourname/Movies/imyholiday/Clip 03.dv clip-2003-09-04 19;00;50.dv
    etc
    and in the Finder all the files are renamed.
    And that's it. You can now import the .dv files into iMovie 09 and it will give the files their proper dates within the system.
    Hope this saves someone some time...

    No, I mean that when I import old iMovie projects into iMovie 08 the 'capture date' of footage is not correctly imported (the .dv file creation date is read in instead). Sorry to confuse the issue with the comment about the camera: I just meant to say that all the equipment I used in my setup is fairly standard yet there is a glaring bug in this fundamental functionality.
    Regarding re-import: it took me ages to originally import my dv tapes to the computer & not really practical to go through that again.
    FWIW, I've not yet imported anything from dv directly into 08

  • Clipping/Bounding Box

    Am looking for some suggestions on the optimal way to do the following.
    Using the data in the table geod_counties, one could request the features and geometries of state='New Hampshire' and county='Hillsborough'. But when one displays the results in a mapping tool such as MapViewer one would also want some of the features/geometries from the 7 counties that TOUCH (or ANYINTERACT) with Hillsborough county. In essence one clips (or cuts) the map around an area of interest creating a box. As far as I understand, other than when applied to LRS, there isn't an explicit clip/box procedure. I have tried a number of ways to do this using SDO_TOUCH, SDO_BUFFER, SDO_RELATE, SDO_INTERSECTION, and a number of others. It appears that a combination of SDO_RELATE and SDO_INTERSECTION is the correct way to do this but I am not clear that this is the optimal way to "create the box" around an area of interest.
    Any comments or advice would be appreciated. And also if someone has written a function to do the above and wouldn't mind sharing, it would be appreciated.
    Thank you.

    I resolved this issue last Friday; am just posting this now. The following appeared to work. In this particular case, the user request is to select geometric features of Hillsborough County, New Hampshire without inputing an x/y starting centroid or a map size as you would find in MapViewer demo applications such as topology.jsp.
    SQL> select sdo_geom.sdo_mbr(a.geom) mbr from geod_counties a where a.state = 'New Hampshire' and county = 'Hillsborough';
    MBR(SDO_GTYPE, SDO_SRID, SDO_POINT (X,Y,Z), SDO_ELEM_INFO, SDO_ORDINATES)
    SDO)GEOMETRY(2003,8307,NULL,SDO_ELEM_INFO_ARRAY(1,1003,3), SDO_ORDINATE_ARRAY(-72.062851,42.696899,-71.246002,43.207188))
    SQL> select sdo_geom.sdo_intersection(geom.sdo_geometry(2003,8037,null,
    sdo_elem_info_array(1,1003,3),sdo_ordinate_array(-72.062751,42.696899,-71.246002,43.207188)),0.0005) int_geom
    from geod_counties a
    where mdsys.sdo_relate(a.geom,sdo_geometry(2003,8307,null,sdo_elem_info_array(1,1003,3),
    mdsys.sdo_ordinate_array(-72.062751,42.696899,-71.246002,43.207188)),
    'mask=anyinteract querytype=window') = 'TRUE;
    Thank you all for your assistance.

  • Recapturing and replacing edited clips with incorrect aspect ratio

    My camera settings were wrong when I captured the video. I edited the clips and discovered my mistake later. I changed the settings and my video looks correct now. The timecode runs perfect on the tape without a break in time. I tried renaming the clip after recapture but the scenes did not match up right. How can I match the timecode during capture. Hope this makes sense.

    My sony hdr-hc1 outputs video with black bars when I record in HD but capture with a 4:3 setting in the TV type setting within the menu. I had changed the setting to SD 4:3 for a different project and forgot to change it back to 16:9 when I captured and edited it. I couldn't find out what was wrong until later. I changed the TV type to 16:9 and it fills the screen now. Even though I recorded in HD which is native 16:9 the TV type setting must match. I think it's pretty crazy myself. Any help on changing the clip out would be great.

  • Finding bounds of nested clipping paths...

    This topic has been touched on before, muppet & sonic have pointed me in the right direction, but I'm stuck right now....
    Seeing as how "saveMultipleArtboards = false" is broken in CS4, and scripting any kind of epsSave results in the artboard size being the bounding box, I am trying to see if I can find out if the "visible to the eye" bounds of artwork exceed the artboard size.
    I can easily find non-clipped objects hanging outside the artboard by comparing the document's visible bounds to the artboard size.
    Likewise the "visible to the eye" bounds of clipped objects :
    var docRef = app.activeDocument;
    docRef.rulerOrigin = [0,0];
    ////Get size of artboard
    var myDocsizeArray = [0,0,docRef.width,docRef.height]
    ////Check for items on page
    if(docRef.pageItems.length != 0){
    /////Find out if top item is clipping mask
    if(docRef.pageItems[0].typename == "GroupItem"){
    if(docRef.pageItems[0].pathItems[0].clipping == true){
    ////Compare its bounds to doc bounds
    var myClipArray = docRef.pageItems[0].pathItems[0].visibleBounds
    if((myClipArray[1] >  myDocsizeArray[3]) || (myClipArray[2] >  myDocsizeArray[2]) || (myClipArray[0] < 0) || (myClipArray[3] < 0)){
    alert("Outside of artboard")
    However, this doesn't work if clipping paths are part of a nested groups. Is there a way to see if a clipping path's parent group is within bounds, or parent's parent group etc. is within bounds. I need to find the topmost clipping path that trumps all the others in any nested group.
    Is that what recursive functions are for? ,,,,,,,,,,,
    Something that can keep looking in a loop within itself?  Very instrospective!
    thx

    Does this help? I use these to position and find bounds based upon what is visible.
    function getRealVisibleBounds(grp) {
         var outerBounds = [];
         for(var i = grp.pageItems.length - 1; i >= 0;i--)  {
              var bounds = [];
              if(grp.pageItems[i].typename == 'GroupItem') {
                   bounds =  getRealVisibleBounds(grp.pageItems[i]);
              else if((grp.pageItems[i].typename == 'PathItem' || grp.pageItems[i].typename == 'CompoundPathItem')
                   && (grp.pageItems[i].clipping || !grp.clipped)) {
                   bounds = grp.pageItems[i].visibleBounds;
              if (bounds.length > 0) {
                   outerBounds = maxBounds(outerBounds,bounds);
         return (outerBounds.length == 0) ? null : outerBounds;
    function maxBounds(ary1,ary2) {
         var res = [];
         if(ary1.length == 0)
              res = ary2;
         else if(ary2.length == 0)
              res = ary1;
         else {
              res[0] = Math.min(ary1[0],ary2[0]);
              res[1] = Math.max(ary1[1],ary2[1]);
              res[2] = Math.max(ary1[2],ary2[2]);
              res[3] = Math.min(ary1[3],ary2[3]);
         return res;
    function positionVisible(grp,x,y)
         var bounds = getRealVisibleBounds(grp);
         var newX = x + (grp.left - bounds[0]);
         var newY = y + (grp.top - bounds[1]);
         grp.position = [newX,newY];

  • Cs3: batch capture in/out edits incorrect

    OK - heres my problem. I have a hdv project which i captured dv files. Ive edited these in the timeline and now want to offline and batch capture as hdv. When i do this however many of the clips appear incorrectly on the timeline. they are slightly off the edits i made - starting several frames before where i made the cut.
    To test it wasn't an error having dv clips in a hdv project i set up a dv project and captured some dv footage. Did some edits on the timeline ( not the program window ) then exported this section, imported it and placed above the edited section on the timeline( so i could use as a comparison ). I then right clicked the captured footage in the project panel - make offline, media files deleted. Then right clicked the captured footage in the project panel - batch capture and captured the footage again. When i compared the footage in the timeline against the saved export the edits were out of sync.
    Not sure if this is at all clear an explanation but heres hoping.
    Many thanks in advance if anyone has any suggestions

    Hi Stan, thanks for the response. I'm sure your description is clear but ive been at this for 20 hours straight so pardon if i am confused. The hdv export has a matching picture/timecode with the Sony FX1E . ie the Premiere Source window of the file shows the same image at the same timecode as the camcorder viewfinder. Premiere is importing the right section. Well what it thinks is the right section. However this is not the section that was on the original timeline -  i can see this by referring to the exported avi i now have on a layer which i use as a reference. I need to check to see if the dv file has the same in/out as the hdv. will need to test on other footage as previously i deleted the files on batch capture.
    Am i following your suggestion correctly?
    Another strange thing happened. I gave edl a go - exported from the project with dv. created a new hdv project and imported the list. Batch captured and still had the same problem - some match some dont. However i transferred to another pc and the same files which were matched on my laptiop were now not matched! How can this be? All i did was transfer the external hard drive ( scratch disc ) to a different pc , hooked the ppro file to them and more unmatching.

  • Relinking spanned clips

    I have received a project edited on PPro 7.1.0 with a number of Canon C300 spanned clips. I have PPro 7.2.1. When I relink the clips the spanned clips link incorrectly. In fact all the span clips have incorrect timecode. The original editor on PPro 7.1.0 brought in the span clips as individual clips with sequential timecode. When I import the clips they come in as clips all of the same length but the time code is way off eg a clip that should start at 01:01:31:17 starts at 01:17:18:18. This is really less than satisfactory and the fact that we need to hand this project back and forth is really going to make life very difficult. Adobe and Canon need to sort this span clip thing out. It's been going on for over a year now at I'm about to start loosing it... a trip to the post office might calm my nerves.

    OK... well it would seem that no one is that interested in this and no one from Abode is willing to help here which is very disappointing.
    Some further developments:
    We are working in 25p PAL btw on apple macs
    1. Both machines now have identical versions of Premiere Pro
    2. Both machines have identical import settings in preferences... are there any other settings hidden anywhere
    Importing mxf footage using Media Browser, shot Canon C300 running 1.0.9.1.00 firmware
    On my import of span clips I get the first of the spans being the full clip with the correct timecode. The other spans are also imported as full clips, but with the timecode starting at the beginning of the final span
    The import on the other editors machine is giving a very different result
    He gets each of the spans as individual clips with each clip being 5:15:21(PAL), which as far as I understand being the maximum span length with the final clip in the span group being shorter than the 5:15:21
    The other interesting thing here is that there are network drives involved at the other editors end and importing from the network drive give slightly different results to importing from a drive via USB3
    While all clips come in as separate clips... no spanning... the clips imported from the network drive are correct sequentuially correct
    The clips from the USB 3 drive will only play the first span of the clip although they are labelled spans xxxx01, xxxx02, xxxx03, etc
    As far as I know my footage was exported to a USB drive from the network drive at the other editors end
    I have imported footage into a new project and sent that project back to the editor... when he relinks the footage he gets the same results as described above
    I am working on a new mac pro... the other editor is on a iMac... the only thing I haven't checked is the version of OSX that he is using
    This now getting very tedious... something that should be very straight forward is now taking hours of time to try and sort out.
    Can someone please help... yes I'm looking at you Mr. Adobe
    cheers
    Pete

  • How to calculate actual selection or group width and height with clipping

    If a group has clipping paths then the height and visible bounds will include the dimensions of all paths selected including the clipped or hidden paths.
    However, the width and height shown on the width and height of the AI detail boxes for the selection shows just the visible dimensions.
    I want to retrieve the same values that is shown on the screen when a group is selected.
    It is somewhat counterintuitive that the "visiblebounds" property does not show just what is visible.
    I'm scaling the visible content of a selection to fit within another path but I need to be able to calculate the dimensions of the only what is visible after clipping.
    What do you have to do with scripting to get these values? Go through all of the path items in a group recursively and save the min and max values of any visiblebounds for clipping paths? Any better alternatives that I don't see?
    Thanks for any help!

    I ended up using the visible bounds for both scale and position as I also discovered that attempting to position a group with the position method would also result in missing the mark. The top and left (x,y) bounds I calculated without the clipped dimensions needed to be used to offset the actual position where I wanted the visible paths to be displayed.
    The functions I used ended up looking like so:
    function GetPoints(dblInch)
         var dpi = 72;
         return dblInch * dpi;
    function getRealVisibleBounds(grp) {
         var outerBounds = [];
         for(var i = grp.pageItems.length - 1; i >= 0;i--)  {
              var bounds = [];
              if(grp.pageItems[i].typename == 'GroupItem') {
                   bounds =  getRealVisibleBounds(grp.pageItems[i]);
              else if((grp.pageItems[i].typename == 'PathItem' || grp.pageItems[i].typename == 'CompoundPathItem')
                   && (grp.pageItems[i].clipping || !grp.clipped)) {
                   bounds = grp.pageItems[i].visibleBounds;
              if (bounds.length > 0) {
                   outerBounds = maxBounds(outerBounds,bounds);
         return (outerBounds.length == 0) ? null : outerBounds;
    function positionVisible(grp,x,y)
         var bounds = getRealVisibleBounds(grp);
         var newX = GetPoints(x) + (grp.left - bounds[0]);
         var newY = GetPoints(y) + (grp.top - bounds[1]);
         grp.position = [newX,newY];
    function maxBounds(ary1,ary2) {
         var res = [];
         if(ary1.length == 0)
              res = ary2;
         else if(ary2.length == 0)
              res = ary1;
         else {
              res[0] = Math.min(ary1[0],ary2[0]);
              res[1] = Math.max(ary1[1],ary2[1]);
              res[2] = Math.max(ary1[2],ary2[2]);
              res[3] = Math.min(ary1[3],ary2[3]);
         return res;
    and were called like so:
    var doc = app.activeDocument;
    if (doc.selection.length > 0) {
         var grpOriginal = null;
         if(doc.selection.length == 1 && doc.selection[0].typename == 'GroupItem') {
              grpOriginal = doc.selection[0];
         else {
              grpOriginal = doc.groupItems.add();
         doc.selection = null;
         if(grpOriginal.layer.name != 'approval') {
              grpOriginal.move(doc.layers['approval'],ElementPlacement.PLACEATEND);
         var artBounds = getRealVisibleBounds (grpOriginal);
         var artWidth = artBounds[2] - artBounds[0];
         var artHeight = artBounds[1] - artBounds[3];
         var imprintHeight = GetPoints(0.625);       // 0.625 is new height, hardcoded for demonstration
         var imprintRatio = imprintHeight / artHeight;
         var section = doc.layers['sectionLeft'];    // section where I placed the art
         var grpArt = grpOriginal.duplicate(section,ElementPlacement.PLACEATEND);
         grpArt.resize(100.0 * imprintRatio,100.0 * imprintRatio);
         grpArt.move(section,ElementPlacement.PLACEATBEGINNING);
         grpArt.selected = true;
         positionVisible(grpArt,0.0,16.75);          // x & y hardcoded for demonstration
    else {
         alert('artwork needs to be selected');
    I'm new at this so are there any better options to do these things?

  • Speeding up clips: fine in FCP, wrong in export

    Hey all, I have a problem with FCP HD. I captured some shots at 720 24p DVCPRO HD off the Panasonic HDV. The shots are about 12 minutes long without an edit. Well, an actor stalled on a line so I made a few edits and sped up parts of the shot to a modest 125% or so. I didn't want the speed up to be very noticeable.
    I managed to shave off 3 seconds or so, which was a good thing. It looks fine in FCP 5. However, when I export to either uncompressed footage or H.264 the speed ups are just jitters. Nothing gets out of sync, the footage just jitters in a strange way. I can't figure out why! It totally seems like a bug. Any help would be appreciated. I would hate to compromise the integrity of the movie just becuase of some software bug.
    Thanks,
    Schmüdde
    www.fermatasonata.com
    www.iamconcrete.com <--- film site.

    Just in case anybody is watching this thread, I found a solution... but not an ideal one.
    Maxplanar's suggestion actually ended up not working. I still got the studdering. I then deleted all the render files... and tried to make sure there wasn't anything cached anywhere that the software might be calling on that made the clip speed incorrect. Still nothing worked.
    The solution? Ugly.
    I changed the clips that were supposed to be running at 100% to 101%. Works without studdering.
    what?
    Wish I knew what the problem was... but at least I have a solution.
    So the time line might look something like this:
    |------|---|---|---|---|---|--------|
    100% 120 101 130 101 123 100%
    Where the clips that are not == 100 or 101% are the clips that I just wanted to speed up a bit. The ones that are at 101% I had to do just so the software would export the timeline correctly.
    Schmüdde

  • Problem with drawing in a scrollpane using clipbounds

    Hello
    Setup is a JFrame containing a splitpane with on the left just some config buttons and on the right a scrollpane.
    Inside the scrollpane I want to draw big waveforms.
    This is represented by a long array of 1's and 0's for the Y coordinates.
    On drawing in paintComponents method I allways reconstruct a GeneralPath, based on the Clipbouns returned by the Graphics variable.
    I have to reconstruct the GeneralPath polygon because my data can be millions long. And therefor I have to limit the points that are drawn.
    When I allways reconstruct this GeneralPath, upon scrolling the polygon is shown scrappy, as in the line connecting the points will only be half shown or almost not.
    Resizing the window or just minimize maximize and it is shown ok.
    I do not have this problem when the GeneralPath I construct is only once made upfront and never remade in the paintComponent method.
    But as I need the clipbounds to know which part to construct I need to rebuild this polygon over and over again.
    I have tried to draw it with Line2D.Double but I get almost the same effect, parts of the lines not being drawn ok.
    Below is the code of the Panel inside the ScrollPane responsible for this drawing.
    public class Usr_Test_L extends JPanel
      final static Color bg   = Color.black;
      final static Color fg   = Color.white;
      final static Color wave = Color.red;
      final static Color txt  = Color.green;
      final static Color grid = Color.lightGray;
      private static final BasicStroke SOLID = new BasicStroke(1.0f);
      private static final BasicStroke BOLD  = new BasicStroke(3.0f);
      private double maxX = 0.0;
      private double maxY = 0.0;
      private double gridWidth;
      private double gridHeight;
      private int panelWidth;
      private int panelHeight;
      boolean firstTime = true;
      private double[] xPoints = null;
      private double[] yPoints = null;
      GeneralPath polygon;
      boolean polyOk = false;
      private double waveHeight = 0;
      private boolean gridOn = true;
      private Usr_Test_R scrollPane = null;
      Usr_Test_L(Usr_Test_R scrollPane)
        super(true);
        this.scrollPane = scrollPane;
        buildGui();
      void buildGui()
        setBackground(bg);
        setForeground(fg);
        //Let the user scroll by dragging to outside the window.
        setAutoscrolls(true); //enable synthetic drag events
    //    addMouseMotionListener(this); //handle mouse drags
        repaint();
      private void generateWave(int cycles, double height)
        waveHeight = height;
        xPoints = new double[cycles];
        yPoints = new double[cycles];
        Random r = new Random();
        for ( int i = 0; i < cycles; i++ )
          xPoints[i] = i;
          yPoints[i] = (int)( Math.pow(-1.0,i) ) * ( r.nextInt(2) );
    //      if ( ( i % 10 ) == 0 ) yPoints[i] = height;
    //      else                   yPoints[i] = height + gridHeight;
    //      System.err.println("P"+i+"("+xPoints[i]+","+yPoints[i]+")");
      private void generateSineWave(int cycles, double height)
        waveHeight = height;
        xPoints = new double[cycles];
        yPoints = new double[cycles];
        double j, xval, yval;
        j = 0;
        int i = 0;
        while (i < cycles)
          xval = j;
          yval = Math.sin(j) * 10.0 + 20;
          xPoints[i] = xval;
          yPoints[i] = yval;
          i++;
          j += 0.01;
      public Dimension getPreferredSize()  // <== used because of revalidate, parent scrollpane asks preferredsize ..., so we overruled the method
        return new Dimension(panelWidth, panelHeight);
      public void drawLine(int cycles, int height)
        generateWave(cycles,(int)(gridHeight*height));
        maxX = gridWidth  * cycles;
        maxY = gridHeight * cycles;
        while ( maxX > panelWidth  ) panelWidth  *= 2;
        while ( maxY > panelHeight ) panelHeight *= 2;
    //    polyOk = buildPolygon();
        revalidate();
        repaint();
      public void drawSine(int cycles, int height)
        generateSineWave(cycles,(int)(gridHeight*height));
        maxX = gridWidth  * cycles;
        maxY = gridHeight * cycles;
        while ( maxX > panelWidth  ) panelWidth  *= 2;
        while ( maxY > panelHeight ) panelHeight *= 2;
    //    polyOk = buildPolygon();
        revalidate();
        repaint();
      public void zoomIn()
        gridWidth  *= 2;
        gridHeight *= 2;
        repaint();
      public void zoomOut()
        gridWidth  /= 2;
        gridHeight /= 2;
        repaint();
      private void initPanel()
        Dimension d = getSize();
        panelWidth = d.width;
        panelHeight = d.height;
        maxX = panelWidth;
        maxY = panelHeight;
        gridWidth  = panelWidth / 8;
        gridHeight = panelHeight / 8;
        scrollPane.getHorBar().setUnitIncrement((int)(gridWidth*3));           // times 2 otherwise no clipbounds are allways too small
        scrollPane.getHorBar().setBlockIncrement((int)(gridWidth*3));
        scrollPane.getVerBar().setUnitIncrement((int)(gridHeight*3));
        scrollPane.getVerBar().setBlockIncrement((int)(gridHeight*3));
      public void grid()
        if ( gridOn ) gridOn = false;
        else          gridOn = true;
      private void drawGrid(Graphics2D g2, Rectangle clip)
        if ( ! gridOn ) return;
        // draw grid
        g2.setPaint(grid);
        // new good grid
        double startX = clip.getX() + ( gridWidth - ( clip.getX() % gridWidth ) );
        double endX   = clip.getX() + clip.getWidth();
        double startY = clip.getY() + ( gridHeight - ( clip.getY() % gridHeight ) );
        double endY   = clip.getY() + clip.getHeight();
        double y = startY;
        while ( startX < endX )
          while ( y < endY )
            g2.draw(new Rectangle2D.Double( startX - 0.5, y - 0.5, 1.0, 1.0 ));
            y += gridHeight;
          y = startY;
          startX += gridWidth;
      private boolean buildPolygon(Rectangle clip)
        if ( xPoints != null && yPoints != null )
          polygon = new GeneralPath(GeneralPath.WIND_NON_ZERO,xPoints.length);
        else
          return false;
        double x = xPoints[0] * gridWidth;
        double y = waveHeight;
        polygon.moveTo((float)xPoints[0], (float)yPoints[0]);
        for ( int index = 0; index < xPoints.length; index++ )
          x = xPoints[index] * gridWidth;
          y = waveHeight + ( yPoints[index] * gridHeight );
          if ( x > ( clip.getX() + clip.getWidth() ) ) break;
          if ( y < clip.getY() || y > ( clip.getY() + clip.getHeight() ) ) continue;
          if ( x < clip.getX() || x > ( clip.getX() + clip.getWidth()  ) ) continue;
          polygon.lineTo((float)x, (float)y);
        return true;
      private boolean drawLines(Graphics2D g2, Rectangle clip)
        if ( xPoints == null || yPoints == null ) return false;
        double x1 = xPoints[0] * gridWidth;
        double y1 = waveHeight;
        double x2, y2;
        boolean cont = false;
        for ( int index = 0; index < xPoints.length; index++ )
          x2 = xPoints[index] * gridWidth;
          y2 = waveHeight + ( yPoints[index] * gridHeight );
          if ( x1 > ( clip.getX() + clip.getWidth() ) )
            break;
          if ( x2 > ( clip.getX() + clip.getWidth() ) )
            break;
          if ( y2 < clip.getY() || y2 > ( clip.getY() + clip.getHeight() ) )
            cont = true;
          if ( x2 < clip.getX() || x2 > ( clip.getX() + clip.getWidth()  ) )
            cont = true;
          if ( ! cont ) g2.draw(new Line2D.Double(x1,y1,x2,y2));
          x1 = x2;
          y1 = y2;
          cont = false;
        return true;
      public void paintComponent(Graphics g)
        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D) g;
        if ( firstTime )
          initPanel();
          firstTime = false;
        // get clip bounds
        Rectangle clip = new Rectangle();
        clip = g2.getClipBounds(clip);
        // draw grid
        drawGrid(g2,clip);
        // draw waveform
        g2.setPaint(wave);
        g2.setStroke(SOLID);
        if ( buildPolygon(clip) ) g2.draw(polygon);
    //    if ( polyOk ) g2.draw(polygon);
    //    drawLines(g2,clip);
      }

    I have added a standalone testcase for ease.
    import java.awt.*;
    import java.awt.geom.*;
    import javax.swing.*;
    import java.util.*;
    public class Scrolling {
        public static void main(String[] args) {
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(new JScrollPane(new DrawPanel()));
            f.setSize(400,300);
            f.setLocationRelativeTo(null);
            f.setVisible(true);
    class DrawPanel extends JPanel {
        private GeneralPath polygon = new GeneralPath(GeneralPath.WIND_NON_ZERO,1000);
        private int[] coords;
        public DrawPanel() {
            setBackground(Color.white);
            buildPolygon();
        private void buildPolygon() {
         coords = new int[2000];
            Random r = new Random();
            int height = 80;
            int gridHeight = 10;
            int gridWidth = 10;
         int j = 0;       
            for (int i=0, dir=-1; i<1000; i++, dir=-dir) {
                coords[j++] = i * gridWidth;
                coords[j++] = height + dir*gridHeight*r.nextInt(2);
        private void drawPolygonClipped(Rectangle clip)
    polygon = new GeneralPath(GeneralPath.WIND_NON_ZERO,1000);
           polygon.moveTo(0,80);
           for ( int i = 0; i < 2000; i++ )
          if ( coords[i] > ( clip.getX() + clip.getWidth() ) ) break;
          if ( coords[i+1] < clip.getY() || coords[i+1] > ( clip.getY() + clip.getHeight() ) ) continue;
          if ( coords[i] < clip.getX() || coords[i] > ( clip.getX() + clip.getWidth()  ) ) continue;
                polygon.lineTo(coords[i++],coords);
    private void drawPolygon(Rectangle clip)
    polygon = new GeneralPath(GeneralPath.WIND_NON_ZERO,1000);
         polygon.moveTo(0,80);
         for ( int i = 0; i < 2000; i++ )
              polygon.lineTo(coords[i++],coords[i]);
    protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D)g;
         Rectangle clip = new Rectangle();
         g.getClipBounds(clip);
         drawPolygonClipped(clip);
         //drawPolygon(clip);
    g2.draw(polygon);
    public Dimension getPreferredSize() {
    return new Dimension(1500,500);

  • BufferedImages and Swing's ScrollablePicture in a JPanel

    I'm referring to http://java.sun.com/developer/technicalArticles/Media/imagestrategies/index.html paper.
    As I read this excellent paper, I decided to go for the BufferedImage strategy.
    But I can't put my BufferedImage into my ScrollablePicture as below:
    JPanel picPanel = new JPanel(new GridBagLayout());
    //Set up the scroll pane.
    picture = new ScrollablePicture(imageIcon_, columnView.getIncrement()); // OK
    //picture = new ScrollablePicture(bImg, columnView.getIncrement()); // NOT OK = don't work
    ...How to bypass the message "java:542: cannot resolve symbol symbol : constructor ScrollablePicture (java.awt.image.BufferedImage,int)"
    It is very important as all my code is based on BufferedImage to apply many operations on the image.
    ? I believe the API does not allow to perform RGB to B&W operation on ImageIcon. ?
    Thanks to all.
    dimitryous r.

    Hi camickr,
    Hi all,
    I pass trough my SSCCE. Good advice from camickr. But it was not so easy:
    Short: not so short
    Self contained: believe so
    Correct: Java 1.4.2 code
    Compilable: yes
    I'm back with formatted code.
    I'm sure you will fire at me all of you. Anyway if I don't even try, I will never succeed.
    //  TooAwoo.java
    //  TooAwoo
    //     part of this code is from Sun's JavaTutorial 1.4.2
    import java.applet.Applet.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.GraphicsEnvironment;
    import java.awt.image.*;
    import java.lang.*;
    import java.lang.String;
    import java.lang.Object;
    import java.net.URL;
    import java.net.MalformedURLException;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.event.MouseInputAdapter;
    import javax.swing.ImageIcon;
    import javax.swing.JScrollPane;
    import javax.swing.JToggleButton;
    import java.io.FilePermission;
    public class TooAwoo extends JApplet implements
                                                                ChangeListener,
                                                                ActionListener,
                                                                ItemListener
         FilePermission p = new FilePermission("<<ALL FILES>>", "read,write");
        public BufferedImage bImg;
         Font newFont = new Font("SansSerif", Font.PLAIN, 10);
         ImageControls RightPanel;
         public static int initOx = 0;
         public static int initOy = 0;
         int init_ww, init_wh, set_x, set_y = 0;
         final int pSP_w = 520; // final width of pictureScrollPane
         final int pSP_h = 650; // final height of pictureScrollPane
         Dimension applet_window; // applet dimensions
         public Image image;
         public ImageIcon imageIcon_;
         public static BufferedImage binull;
         // ScrollablePicture stuff
         public Rule columnView;
        public Rule rowView;
         public JToggleButton isMetric;
        public ScrollablePicture picture;
         public JScrollPane pictureScrollPane;
         public TooAwoo() {
              // nothing here
        public void init() {
              applet_window = getSize();                                                            // read applet dimensions in TooAwoo.html
              init_ww = applet_window.width;
              init_wh = applet_window.height;
              // get the image to use width > 680 (see final int pSP_w above)
              image = getImage(getDocumentBase(), "images/ReallyBig.jpg");
              imageIcon_ = createImageIcon("images/ReallyBig.jpg");
              int iw = imageIcon_.getIconWidth();
              int ih = imageIcon_.getIconHeight();
              bImg = new BufferedImage(iw, ih, BufferedImage.TYPE_INT_RGB);
              // Panels
              // ImageDisplayPanel
            //Create the row and column headers.
            columnView = new Rule(Rule.HORIZONTAL, true);
            rowView = new Rule(Rule.VERTICAL, true);
            if (imageIcon_ != null) {
                columnView.setPreferredWidth(imageIcon_.getIconWidth());
                rowView.setPreferredHeight(imageIcon_.getIconHeight());
            } else {
                columnView.setPreferredWidth(640);
                rowView.setPreferredHeight(480);
            //Create the upper left corner.
            JPanel buttonCorner = new JPanel();                                                  //use FlowLayout
            isMetric = new JToggleButton("cm", true);
            isMetric.setFont(newFont);
            isMetric.setMargin(new Insets(2,2,2,2));
            isMetric.addItemListener(this);                                                       // !!! not OK = don't work: button is not firing
            buttonCorner.add(isMetric);
              JPanel ImageDisplayPanel = new JPanel(new GridBagLayout());
            //Set up the scroll pane.
              picture = new ScrollablePicture(imageIcon_, columnView.getIncrement());     // either
              //picture = new ScrollablePicture(bImp, columnView.getIncrement());          // or
              // ********** if bImp change the lines in ScrollablePicture.java **********
            Graphics g = bImg.getGraphics();
              g.drawImage(bImg, 0, 0, null);
              JScrollPane pictureScrollPane = new JScrollPane(picture);
            pictureScrollPane.setPreferredSize(new Dimension(pSP_w, pSP_h));
            pictureScrollPane.setViewportBorder(
                    BorderFactory.createLineBorder(Color.black));
            pictureScrollPane.setColumnHeaderView(columnView);
            pictureScrollPane.setRowHeaderView(rowView);
              //Set the corners.
            pictureScrollPane.setCorner(JScrollPane.UPPER_LEFT_CORNER, buttonCorner);
            pictureScrollPane.setCorner(JScrollPane.LOWER_LEFT_CORNER,
                                        new Corner());
            pictureScrollPane.setCorner(JScrollPane.UPPER_RIGHT_CORNER,
                                        new Corner());
              //set_y++;
              addToGridBag(ImageDisplayPanel,pictureScrollPane, set_x, set_y, 1, 1, 0, 0); // 0,0
              getContentPane().add( BorderLayout.WEST, ImageDisplayPanel);               // where to display the bImg: left
              RightPanel = new ImageControls();                                                  // call the ImageControls class
              RightPanel.setBackground(Color.black);
              getContentPane().add( BorderLayout.EAST, RightPanel);
              //getContentPane().add( BorderLayout.EAST, ToolsPanel);                         // where to display the tools: right
              JPanel GlobalPanel = new JPanel(new GridBagLayout());
              getContentPane().add( BorderLayout.NORTH, GlobalPanel);
         } // end public void init()
         public Graphics2D createGraphics2D(int width,
                                                    int height,
                                                    BufferedImage bi,
                                                    Graphics g) {                                   // called by ImageControls paint
              Graphics2D g2 = null;
              if (bi != null) {
                   System.out.println("TooAwoo createGraphics2D: bi != null : " + " w= " + width + " h= " + height);
                   g2 = bi.createGraphics();
              } else {
                   System.out.println("TooAwoo createGraphics2D: bi == null g2 = (Graphics2D) g");
                   g2 = (Graphics2D) g;
              return g2; // return to ImageControls paint
         } // end createGraphics2D
         class ImageControls extends JPanel {
              public void paint(Graphics g) {
                   Dimension applet_window = getSize();
                   if (bImg == null) {
                        bImg = createBufferedImage(applet_window.width, applet_window.height, 2);
                   } else {
                        Graphics2D g2 = createGraphics2D(applet_window.width, applet_window.height, bImg, g);
                        g.drawImage( bImg , initOx , initOy , null );
                        g2.dispose();
                        //toolkit.sync();
                   } // end else (bImg != null)
              } // end paint
         } // end ImageControls
         public Dimension setPreferredSize() {
              Dimension applet_window = getSize();
              return applet_window;
         public String getString(String key) {
              return key;
         public BufferedImage createBufferedImage(int w, int h, int imgType) {          // called by ImageControls paint
              BufferedImage bi = null;
              if (imgType == 0) {
                   bi = (BufferedImage) getGraphicsConfiguration().createCompatibleImage(w, h);
              } else if (imgType > 0 && imgType < 14) {
                   bi = new BufferedImage(w, h, imgType);
              System.out.println("TooAwoo createBufferedImage: imgType= " + imgType + " w= " + w + " h= " + h);
              return bi;
         public static void addToGridBag(JPanel panel, Component comp,
                                                 int x, int y, int w, int h, double weightx, double weighty) {
              GridBagLayout gbl = (GridBagLayout) panel.getLayout();
              GridBagConstraints c = new GridBagConstraints();
              c.fill = GridBagConstraints.BOTH;
              c.anchor = GridBagConstraints.WEST;
              c.gridx = x;
              c.gridy = y;
              c.gridwidth = w;
              c.gridheight = h;
              c.weightx = weightx;
              c.weighty = weighty;
              panel.add(comp);
              gbl.setConstraints(comp, c);
         } // end addToGridBag
         protected static ImageIcon createImageIcon(String path) {                         // Returns an ImageIcon, or null if the path was invalid.
              java.net.URL imgURL = TooAwoo.class.getResource(path);
              if (imgURL != null) {
                   return new ImageIcon(imgURL);
              } else {
                   System.err.println("Couldn't find file: " + path);
                   return null;
         } // end createImageIcon
         private static void createAndShowGUI() {                                             // called by main
              JFrame frame = new JFrame("TooAwoo");                                             //Create and set up the window.
              // Make sure we have nice window decorations.
              frame.setDefaultLookAndFeelDecorated(true);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              // Create and set up content pane.
              frame.addWindowListener(new WindowAdapter() {
                   public void windowClosing(WindowEvent e) {
                        System.exit(0);
              JPanel masterPanel = new JPanel();
              frame.add("Center", masterPanel);
              // Display the window.
              frame.pack();
              frame.setSize(new Dimension( 1000 , 640 ));
              frame.setVisible(true);
         } // end createAndShowGUI
         public static void main(String s[]) {
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                        createAndShowGUI();
         } // end main
         public void actionPerformed(ActionEvent e) {
              repaint(1024);
        public void stateChanged(ChangeEvent e) {
              repaint(1024);
         public void itemStateChanged(ItemEvent e) {
              Object obj = e.getSource();
              if ( obj == isMetric ) {
                   System.out.println("obj isMetric");
                //Turn it to metric.
                rowView.setIsMetric(true);
                columnView.setIsMetric(true);
                   picture.setMaxUnitIncrement(rowView.getIncrement());
            } else {
                System.out.println("obj isNotMetric");
                   //Turn it to inches.
                rowView.setIsMetric(false);
                columnView.setIsMetric(false);
                   picture.setMaxUnitIncrement(rowView.getIncrement());
         } // end itemStateChanged(ItemEvent e)
    } // end TooAwoo
    Next is ScrollablePicture.java
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import javax.swing.*;
    import javax.swing.border.*;
    public class ScrollablePicture extends JLabel implements Scrollable {
        private int maxUnitIncrement = 1;
         private boolean missingPicture = false;
        public ScrollablePicture (ImageIcon imageIcon_, int m){                              //(BufferedImage bImg, int m)
            super(imageIcon_); // comment this line if bImg...
              if (imageIcon_ == null) { // change imageIcon_ to bImg if bImg...
                   missingPicture = true;
                   setText("No picture found.");
                   setHorizontalAlignment(CENTER);
                   setOpaque(true);
                   setBackground(Color.black);
              maxUnitIncrement = m;
        public Dimension getPreferredScrollableViewportSize() {
            return getPreferredSize();
        public int getScrollableUnitIncrement(Rectangle visibleRect,
                                              int orientation,
                                              int direction) {
            //Get the current position.
            int currentPosition = 0;
            if (orientation == SwingConstants.HORIZONTAL)
                currentPosition = visibleRect.x;
            else
                currentPosition = visibleRect.y;
            //Return the number of pixels between currentPosition
            //and the nearest tick mark in the indicated direction.
            if (direction < 0) {
                int newPosition = currentPosition -
                   (currentPosition / maxUnitIncrement) *
                   maxUnitIncrement;
                return (newPosition == 0) ? maxUnitIncrement : newPosition;
            } else {
                return ((currentPosition / maxUnitIncrement) + 1) *
                   maxUnitIncrement - currentPosition;
        public int getScrollableBlockIncrement(Rectangle visibleRect,
                                               int orientation,
                                               int direction) {
            if (orientation == SwingConstants.HORIZONTAL)
                return visibleRect.width - maxUnitIncrement;
            else
                return visibleRect.height - maxUnitIncrement;
        public boolean getScrollableTracksViewportWidth() {
            return false;
        public boolean getScrollableTracksViewportHeight() {
            return false;
        public void setMaxUnitIncrement(int pixels) {
            maxUnitIncrement = pixels;
    Next is Corner.java
    import java.awt.*;
    import javax.swing.*;
    public class Corner extends JComponent {
        protected void paintComponent(Graphics g) {
            g.setColor(new Color(230, 163, 4));
            g.fillRect(0, 0, getWidth(), getHeight());
    Next is Rule.java
    import java.awt.*;
    import javax.swing.*;
    public class Rule extends JComponent {
        public static final int INCH = Toolkit.getDefaultToolkit().
                getScreenResolution();
        public static final int HORIZONTAL = 0;
        public static final int VERTICAL = 1;
        public static final int SIZE = 30;
        public int orientation;
        public boolean isMetric;
        private int increment;
        private int units;
        public Rule(int o, boolean m) {
            orientation = o;
            isMetric = m;
            setIncrementAndUnits();
        public void setIsMetric(boolean isMetric) {
            this.isMetric = isMetric;
            setIncrementAndUnits();
            repaint();
        private void setIncrementAndUnits() {
            if (isMetric) {
                units = (int)((double)INCH / (double)2.54); // dots per centimeter
                increment = units;
            } else {
                units = INCH;
                increment = units / 2;
        public boolean isMetric() {
            return this.isMetric;
        public int getIncrement() {
            return increment;
        public void setPreferredHeight(int ph) {
            setPreferredSize(new Dimension(SIZE, ph));
        public void setPreferredWidth(int pw) {
            setPreferredSize(new Dimension(pw, SIZE));
        protected void paintComponent(Graphics g) {
            Rectangle drawHere = g.getClipBounds();
            // Fill clipping area with dirty brown/orange.
            g.setColor(new Color(230, 163, 4));
            g.fillRect(drawHere.x, drawHere.y, drawHere.width, drawHere.height);
            // Do the ruler labels in a small font that's black.
            g.setFont(new Font("SansSerif", Font.PLAIN, 10));
            g.setColor(Color.black);
            // Some vars we need.
            int end = 0;
            int start = 0;
            int tickLength = 0;
            String text = null;
            // Use clipping bounds to calculate first and last tick locations.
            if (orientation == HORIZONTAL) {
                start = (drawHere.x / increment) * increment;
                end = (((drawHere.x + drawHere.width) / increment) + 1)
                      * increment;
            } else {
                start = (drawHere.y / increment) * increment;
                end = (((drawHere.y + drawHere.height) / increment) + 1)
                      * increment;
            // Make a special case of 0 to display the number
            // within the rule and draw a units label.
            if (start == 0) {
                text = Integer.toString(0) + (isMetric ? " cm" : " in");
                tickLength = 8;//10;
                if (orientation == HORIZONTAL) {
                    g.drawLine(0, SIZE-1, 0, SIZE-tickLength-1);
                    g.drawString(text, 2, 21);
                } else {
                    g.drawLine(SIZE-1, 0, SIZE-tickLength-1, 0);
                    g.drawString(text, 9, 10);
                text = null;
                start = increment;
            // ticks and labels
            for (int i = start; i < end; i += increment) {
                if (i % units == 0)  {
                    tickLength = 7;//10;
                    text = Integer.toString(i/units);
                } else {
                    tickLength = 4;//7;
                    text = null;
                if (tickLength != 0) {
                    if (orientation == HORIZONTAL) {
                        g.drawLine(i, SIZE-1, i, SIZE-tickLength-1);
                        if (text != null)
                            g.drawString(text, i-3, 21);
                    } else {
                        g.drawLine(SIZE-1, i, SIZE-tickLength-1, i);
                        if (text != null)
                            g.drawString(text, 9, i+3);
    Here is TooAwoo.html
    <HTML>
    <HEAD>
    <TITLE>TooAwoo</TITLE>
    </HEAD>
    <BODY>
    <APPLET archive="TooAwoo.jar" code="TooAwoo" width=1024 height=800>
    Your browser does not support Java, so nothing is displayed.
    </APPLET>
    </BODY>
    </HTML>
    */Total number of lines: 486
    Weight: 15 199 bytes
    Total number of files: 5
    TooAwoo.java
    ScrollablePicture.java
    Corner.java
    Rule.java
    TooAwoo.html
    ... in that order in my code
    The major default is: I cannot have that BuffuredImage at the left of the screen if run using bImp at line 91 of TooAwoo.java.
    Minor bug: the JToggle button (inch/cm) does not fires-up correctly. Nothing change.
    Anyway feel free to fire at me if you believe its a good strategy. I will remain very positive to all comments and suggestions.
    Thanks.
    dimitryous r.

Maybe you are looking for

  • How can I find out if my iphone has been synced to another computer? (Backup/Sync Privacy)

    So it would seem easy for someone (lets just say a girlfriend for example) to plug my iPhone into her computer while I am staying the night and backup to iTunes.  I have my settings to "require a passcode immediately", however there was one day there

  • TimeMachine interruption during initial backup to external hardrive

    Dear All, I was using TimeMachine for the first time on a QNAP NAS. It was plodding along quite well and I stupidly decided to change the IP address of my NAS with about 5 gigs of 160gig backup left to go. TimeMachine obviously lost the drive so I de

  • Thumbnail with dynamic images

    I'm trying to create a thumbnail object for an HLIST, the data for the thumbnail is a bytearray containing an image in PNG format. The data comes from a database in an AMF object via FDS. I can see the data in the debugger, and it is not null, but I'

  • T500 praise

    Hi everyone, Got my brand new T500 a week ago, tried a SL500 for 3 weeks, but decided i did'nt like the keyboard layout (why are lenovo the only one with the ins/home/pgup - del/end/pgdn buttons in a 3 under 3 config - all other vendors throws these

  • Getting error msg while using SFP tcode to use intaractive ADOBE forms

    Hi All, I wanna make use of Adobe intractive forms in one application. when i use transaction SFP and click on the layout tab i get following error message. Could not start Layout Designer (see long text) Message no. FPUIFB086 Diagnosis The forms des