Fill a rounded rectangle with a gradient paint with "new RoundRectangle2D"?

Hello,
at the moment I have to do a lot of Java2D to draw a customized GUI. Now it comes to a simple task, filling a rounded rectangle with a gradient paint. I have a solution for this - but I don't know if it is bad to do it this way:
private void drawBackground( Component component, Graphics2D graphics2d ) {
     int w = component.getWidth() - 1;
     int h = component.getHeight() - 1;
     graphics2d.setPaint( gradientPaint );
     RoundRectangle2D backgroundShape =
          new RoundRectangle2D.Float( 0, 0, w, h, 10, 10 );
     graphics2d.fill( backgroundShape );
}This is very easy and it works. The backdraw is, that on every call of "drawBackground", which is called on a repaint() method by Swing, a "new RoundRectangle2D.Float" will be created. I don't know how "expensive" it is to create a new RoundRectangle2D. On the other hand, I don't know how to fill a rounded rectangle with a gradient paint without a RoundRectangle2D.
When I do it this way, I worry that at a later time, when I created a lot of custom components that all create shapes on a repaint, the GUI may become horrible slow or has a huge memory footprint.
Well, I would like to hear some kind of "this is okay" (maybe because those Shape implementation are all not very memory consuming and the instanciation in Java is not very time consuming) by you Java2D experts :) Or, of course, how I could do it better.
Thanks a lot for your help!

patb1 wrote:
on every call of "drawBackground", which is called on a repaint() method by Swing, a "new RoundRectangle2D.Float" will be created. I don't know how "expensive" it is to create a new RoundRectangle2D.
When I do it this way, I worry that at a later time, when I created a lot of custom components that all create shapes on a repaint, the GUI may become horrible slow or has a huge memory footprint.You could do as many UI delegates in the Swing code do with Rectangles: maintain a RoundRectangle2D as a field and set its attributes when it is to be painted (setRoundRect(double x, double y, double w, double h, double arcw, double arch)).
db

Similar Messages

  • I want to draw rounded rectangle with dashed border

    Hello,
    I am working on flex 4.5 air 2.7 . And i want to draw rounded rectangle which has dashed border or solid border as per user's selection. Also rectangle can be rounded or simple. I am able to draw simple rectangle with dashed border. I want a solution for rounded rectangle.
    If anyone have any idea then post as soon as possible..
    Thanks
    Dhwani

    Good day!
    Could you please post a screenshot with the Layers Panel visible?
    Is the iten by any chance a Shape Layer and therefore does have a Vector Mask?
    Regards,
    Pfaffenbichler

  • Spark - Drawing a rounded rectangle with 3-sided border?

    I am upgrading to the Spark theme, and I am trying to draw a rectangle, with a corner radius of 20, with a border on only the top, right, and bottom sides.
    Basically, I want it to dock flush left in my application and extend out in a rounded rectangle.
    But I Cannot figure out how I would draw this in SVG? Anyone done this yet?

    Ned,
    Thank you for your response.  I apologize for the delay in my own response.
    I was seeing distortion in x direction as well.
    I was able to solve my problem using 9-slice scaling.  I used the scale9Grid property.

  • ISA 4.0 filling in the extension with new field from JSP

    Has anyone tried to fill in the extension structure from JSP like the order.jsp?  Using the OSS note, 454715 there seems to be a way to do this.  For outbound, it works with the name, value pair but I am having problem for inbound.  Follwing is the code for order.jsp and the BAdI; this should eliminate the need for creating the backend object, business object and XCM Configurations.
    - Order.jsp
    <%
    //Choi- Reason Code Entry
         (BusinessObjectManager.ISACORE_BOM);
             Basket basket = isaBOM.getBasket();
              String extBasketHeaderData = (String)request.getAttribute("ZCust1");
                  basket.addExtensionData("ZCust_field1", extBasketHeaderData);
    %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
      <head>
    2. BAdI;  CRM_ISA_BASKET_HEAD-changehead_before_order, 
    method if_ex_crm_isa_basket_head~changehead_before_order .
    data: is_it_extension type crmt_isales_extension,
          is_ct_orderadm_h type crmt_orderadm_h_com.
    data ls_cs_basket_head type crmt_isales_baskethead_ui.
    *clear ls_extension.
      loop at it_extension into is_it_extension.
        if is_it_extension-name = 'ZCust_field1'.
         CS_BASKET_HEAD-DESCRIPTION = ls_extension-value.
          append is_ct_orderadm_h to ct_orderadm_h.
        endif.
      endloop.
    endmethod.

    Hi Kyo,
    How did you do it?
    Regards,
    Michael Goossens

  • Dynamically fill the internal table with new fileds

    Hi Friends,
    I have the internal table like
    Data:begin of i_data occurs 0,
               a(60),
                b(60),
                c(60),
                d(60),
                 e(60),
            end of i_data.
    I need to fill the internal table dynamically like
    Data:begin of i_data occurs 0,
               a(60),
                b(60),
                c(60),
                 c1(60),  "new filed dynamically
                 c2(60),  "new field dynamically
                d(60),
                 e(60),
            end of i_data.
    Please suggest me how to do this.
    Regards,
    Sunny.
    Code Formatted by: Alvaro Tejada Galindo on Jan 8, 2009 1:55 PM

    You can not add new fields to a statically defined internal table, instead you must create the entrie internal table at runtime.
    Search this forum for Dynamic Internal tables, you will get a lot of example programs.
    Regards,
    Rich Heilman

  • PSE 5: Creating a rounded rectangle not filled in.

    I want to create a rounded rectangle with the rounded rectangle tool, but I don't want it filled it with color, just outline / stroke.  I see it's been discussed here but I can't figure it out.  Any advance would be great.  

    Another way, in addition to the ways posted above, is to draw out
    your shape.
    Then go to layer styles and find the style set named visibility.
    There are three styles there: show, hide and ghosted. Pick the
    hide style and your color will be hidden. Then Alt+double click
    on the shape thumbnail to bring up the layer style settings
    dialog. At the bottom of the dialog is a stroke option, where you can
    choose your stroke color, size and opacity.
    The advantage of this way is you can edit the settings later by double
    clicking on the small fx beside the shape layer.
    If you wish to restore the color later, you can use the show style in the
    visibility layer style set.
    Later versions of photoshop elements work the same way.
    MTSTUNER

  • Premiere Pro cs6 How to adjust radius of rounded rectangle

    I think my title covers my question.
    How do I adjust radius of rounded rectangle in Premiere Pro CS6? Trying to make a lower third and don't want the exaggerated rounded corner.  Is there a way to adjust the radius of the corner?
    Thanks

    how about using the pen tool? Either place your rounded rectangle in your spot (to use as a template, guide to line up, or practice pen) and draw over with the pen tool
    or, draw your rounded rectangle with the pen (no guide)
    with the pen - properties - graphic type - choose 'filled bezier'
    EDIT - just using the rounded rectangle tool, gives the properties- graphic type - round rectangle (ah, but then I also see a 'rounded corner rectangle')
    so, change option to 'filled bezier' and either delete middle anchor point of corner and use convert anchor point tool to pull out corners
    or - change option to 'filled bezier' choose pen tool, select middle anchor point, click, hold and move to your choice
    or I have misunderstood your rounded rectangle to be either
    1. round rectangle
    2. rounded corner rectangle

  • Creating Rounded Rectangle Outline Colour Issue

    Hi all,
    I am wanting to create a rounded rectangle, with an outline or boarder with a colour black (Or other colours). But i am unable to find where i'm able to add an outline colour as an option before drawing out the shape or after drawing the shape.
    The only option i am able to do is changing the background colour of the shape created, and i was wondering if you are able to add an outline when creating or after creating a rounded rectangles or other shapes...
    Thanks,
    James

    But i am unable to find where i'm able to add an outline colour as an option before drawing out the shape or after drawing the shape.
    Styles -> Stroke.

  • Rounded Rectangle Line Weight problem

    I can't make a rounded rectangle with .5pt. It keeps resetting to 1pt. I am also applying a dash (1,1) to the line

    rwl3,
    You may have Align to Pixel Grid ticked in the Transform palette. You can see it when the object is selected.
    If so, you probably have Align New Objects to Pixel Grid ticked in the Options.
    To cure this, you may select everything and untick both.

  • Fix the pathetic rounded-rectangle tool.

    Ugh, why do we waste our time?
    I made a rounded rectangle with the rounded-rectangle tool.  Then, as often happens, I needed to change the corner radius.  Of course the "help" was useless, so a Web search revealed that YOU CAN'T CHANGE THE RADIUS.
    Can I get a WTF here?
    Oh, but then I read that there's an alternate way to create a rounded rectangle, which is to draw a regular rectangle and then apply a rounded-rectangle "effect" to it.
    Dare I ask the question that should be obvious to even the most computer-illiterate imbecile in the audience:  Why didn't the rounded-rectangle tool do this in the first place?

    Anyone being harsh on Corel Draw hasn't compared it to Illustrator.  Illustrator's useless selection mode alone is a deal-breaker: http://www.flickr.com/photos/forensicpics/1800773495/in/set-72157600304785497

  • Bug report about create new footprint with Rounded rectangle in 3D info Bottom

    I create new footprint with rounded rectangle in 3D info Bottom,the rounded rectangle must be in bottom,but In fact,the rounded rectangle
    created in top layer.i think it's wrong.
    I used ultiboard 10.1.357.

    Hi,
    Thank you for reporting this. This has been a long standing issue with Ultiboard and we are looking into resolving this.
    There is a work around although a very inconvenient one. You can set the height to what you require and use a negative offset to move the shape to the other side of the board. The 3D shape will appear on the other side, but in reality is just shifted, not mirrored.
    Hope that helps. We apologize for the inconvenience.
    Yi
    Software Developer
    National Instruments - Electronics Workbench Group

  • Rectangle with 2 sides sqare and 2 rounded

    lets say i have the body rectangtle, and i want the top part
    to have rounded corners but the bottom part to have squrare
    corners. i cant seem to use the marquee tool to cut off part of it
    like i do in photoshop. or i can seem to join a rounded rectancle
    and a square one. to export to make a web page i cant have
    overlapping pieces. so how do i acomplish this. thanks

    zoom4267 wrote:
    > lets say i have the body rectangtle, and i want the top
    part to have rounded
    > corners but the bottom part to have squrare corners. i
    cant seem to use the
    > marquee tool to cut off part of it like i do in
    photoshop. or i can seem to
    > join a rounded rectancle and a square one. to export to
    make a web page i
    > cant have overlapping pieces. so how do i acomplish
    this. thanks
    Use the Rounded rectangle vector shape to draw the rectangle.
    Adjust two
    of the corners either in the Auto Shape Properties panel, or
    by pressing
    Alt and adjusting the corners manually.
    Linda Rathgeber - Adobe Community Expert
    http://www.adobe.com/communities/experts/members/8.html

  • How to make ROUNDED rectangle default style cp8?

    Hi,
    I want my smart shape style to be rounded rectangle, not squared. I have set up my object styles with color and all that good stuff, but there is no way I can see to make it the rounded shape instead of the squared off shape.  I also tried to change one on the properties panel thinking I could "apply to all" but that option is not available.  I am trying to use smart shapes as my captions in recording and it sure would be nice not to have to touch every single one and change it to rounded - defeats the purpose of styles, yes?
    Using CP8, latest version (I checked and there are no updates available), on a windows machine, 64 bit.
    Thanks!!!
    Kelly

    Rick, that option has effect on the captions inserted while creating a software simulation.
    @LMS_90 About which shapes as Text container are you talking? Object styles for Shapes do not include the 'form' of the shape. And at this moment, you cannot set such a form as being included in the default style, with the one exception that Rick points out: added text during a simulation capture.
    Even for Success/Failure/Hint shapes you cannot define that it always has to be a rounded rectangle. For Question slides, you can set them up in the master slides, and if you use always master slides with placeholders it is also possible. Quite a lot of the default themes have rounded rectangle shapes as text container for Title and Subtitle.
    Also in the Properties the 'form' is not part of the style: if you apply the default Shape Style that includes Stroke, Fill, Character properties, Margins, Shadow...but not the shape itself. That is the reason why 'Apply to all' cannot be used for the shape form.
    This is probably not the answer you expected, I try to change as much as possible in the Master slide.

  • OBIEE 11g - change bar graph result to "rectangle" instead of "gradient"

    Hi, I'm a big believe in Stephen Few's theory that anything that adds extra ink and/or causes visual distraction is poor design for presenting information. I've already figured out how to remove the shadow effect from all graphs (by setting visualEffects="NONE" in the dvt-graph-skin.xml).
    I've noticed that simple bar graphs default to using a "gradient" fill (a.k.a. extra visual distraction), instead of just being a flat rectangle. I can change this on a graph by graph basis by setting the graph data style to "rectangle", but I have to do this every time. Is there a simple way to change the default to be "rectangle" instead of "gradient"?
    Thanks!
    Scott

    Not yet, and I've been too busy with some SEV 1 issues to goof around with it. I also need to open a ticket about default pivot table formatting - i.e. removing the background colors under the non-data areas, and they also seem to have some sort of gradient fill at the bottom. I'll let you know if I hear anything.
    Thx,
    Scott

  • Jagged edges when using rounded rectangle

    Hi,
    Hope someone can help me here.
    I am designing a website for myself (first timer) and have created menu bars and buttons using the rounded rectangle tool.
    The images look good but the edges are pixelated.
    I am using anti-alias and have also try feathered but to no avail.
    When I preview the site in the browser I can still see the pixelated edges (I assumed it might be a magnification or resolution issue)
    I am not using any images, have not extracted etc. I am simply using the rounded rectangle to create a menu bar and then colouring it in as a gradient, adding text and that's pretty much it.
    Any help given here will be greatly appreciated.
    Thanks,
    Eddie

    You shouldn't see anything in the browser that you don't see in Fireworks. If you have magnified your view by zooming your browser, then reset it to normal zoom. If that isn't the problem...
    One thing you can try is to make your navigation images 2 or 4 times larger than you want, export the files, import them and reduce them to 50% or 25%, depending. Sometimes, you can get what appears to be a smoother edge by reduction than you can with Firework's anti-aliasing of rounded shapes.

Maybe you are looking for

  • XI--- OpenJMS error  Object not found in lookup of XIJMSService

    Hi all, I am trying XI-->OpenJms (Server). I have included openJms.jar library in aii_af_jmsproviderlib.sda and deployed using SDM. In JMS receiver adapter I am using the following Configuration: Transport protocol: JMS Provider with JNDI . Queue con

  • Is it normal for my computer to turn on then off then on again?

    Sometimes when I turn my computer on it turns off then it turns on.  I have not had any other problems with this and there is no error in the debug.  My friends Maximus 775 board used to do this a lot to.  Is this an intel thing? Specs gd-80 i5 750 a

  • Rule based metadata value population

    Hi, We have a requirement where the assets metadata associated with the asset should be displayed based on rule. For example if there are 3 dropdowns. On choosing the value in dropdown 1, the values in the dropdown 2 should be displayed and similarly

  • Crazy iTunes Mess

    Hello Apple Community, I need someone's help! I've been trying to fix my iPhone 4S for hours and up to this point I don't know what to do anymore. It all started yesterday, iCloud kept popping up requesting me to put in my password; the same thing ha

  • Automatic text comparison does not work from child to Master in CUA

    Hi, When trying to transfer role specifications to CUA master from our child system the application log is displaying as seen in slg1.png. On our master system we are running 7.31 SP7 which is fine according to Note 1642106. Our client system is 7.31