Side effects when using Graphics2D.drawString

Hi! I am trying to render some texts in different places on a JPanel. I use Graphics2D.drawString(String, float , float). My problem is that the AffineTransform of the Graphics2D-object changes after each time I use the method. Should this really be the case? If so, do I need to reset the transformation object in the Graphics2D-object after each call to Graphics2D.drawString or how should I go about it? An example of a set of code and the yielded output is below:
                    System.out.println("graphics transform (before drawLine): " + g2.getTransform());
                    g2.drawString("test", 150, 50);
                    System.out.println("graphics transform (after drawLine): " + g2.getTransform());
yields:
graphics transform (before drawLine): AffineTransform[[1.0, 0.0, 0.0], [0.0, 1.0, 23.0]]
graphics transform (after drawLine): AffineTransform[[1.0, 0.0, 150.0], [0.0, 1.0, 73.0]]

Trying to produce a small set of code that reproduces the error made me solve the problem, though I do not understand why. Anyhow, I am using Java 1.4.1, and use Mac OS. Code that reproduces the error is below. By uncomment the line ' g2.setColor(Color.black);', the problem dissapears. But please let me know if anyone have an explanation to why setting a gradient paint makes Graphics2D.drawString have the side effect I described above...
import java.util.*;
import java.awt.*;
import javax.swing.*;
public class Plotter extends JFrame {
     public Plotter() {
          super("Debug");
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          Dimension contentSize = new Dimension(500, 500);
          pack();
          setSize(contentSize);
          setVisible(true);
     public void paint(Graphics g) {
          super.paint(g);
          Graphics2D g2 = (Graphics2D) g;
          g2.setPaint(new GradientPaint(0, 0, Color.green, 100, 0, Color.red, true));
//          g2.setColor(Color.black);
          System.out.println("graphics transform (before drawLine): " + g2.getTransform());
          g2.drawString("test", 150, 50);
          System.out.println("graphics transform (after drawLine): " + g2.getTransform());     
     public static void main(String args[]) {
          new Plotter();

Similar Messages

  • Side effects of using catmeta.sql?

    Not exactly sure where to put this, but I've been having problems exporting, mostly around the XMLGEN part. It seems that the solution would be to rebuild all the views and whatnot, but since this is a live database, I'd like to know if there are any side effects accompanying using catmeta.sql or any of the related files.
    Thanks in advance!

    Running Oracle9i Enterprise Edition Release 9.2.0.6.0 - Production under Windows XP. The error comes from exporting and comes up as
    Connected to: Oracle9i Enterprise Edition Release 9.2.0.6.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.6.0 - Production
    Export done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
    About to export specified users ...
    . exporting pre-schema procedural objects and actions
    . exporting foreign function library names for user TEST
    . exporting PUBLIC type synonyms
    . exporting private type synonyms
    . exporting object type definitions for user TEST
    About to export TEST's objects ...
    . exporting database links
    . exporting sequence numbers
    . exporting cluster definitions
    EXP-00056: ORACLE error 19206 encountered
    ORA-19206: Invalid value for query or REF CURSOR parameter
    ORA-06512: at "SYS.DBMS_XMLGEN", line 83
    ORA-06512: at "SYS.DBMS_METADATA", line 345
    ORA-06512: at "SYS.DBMS_METADATA", line 410
    ORA-06512: at "SYS.DBMS_METADATA", line 449
    ORA-06512: at "SYS.DBMS_METADATA", line 1156
    ORA-06512: at "SYS.DBMS_METADATA", line 1141
    ORA-06512: at line 1
    EXP-00000: Export terminated unsuccessfully

  • Is there a way to remove the blurred background wallpaper effect when using the phone in iPhone 4S' iOS 7?

    Hello.
    A few nights ago, my picky client finally upgraded his iPhone 4S' iOS 6 to iOS 7. He doesn't like the blurred background wallpaper image when using the phone feature (e.g., calling and talking). Is there a way to disable this new visual effect like in iOS 6?  I am pretty sure this is by design by Apple.
    Thank you in advance.

    sberman wrote:
    I'm not completely sure I understand, but ...
    Might Settings > General > Accessibility > Reduce Motion = "On" do what the customer wants?
    I will tell him about that, but I don't think that would be it if that is related to animation.
    We're talking about the wallpaper background that get blurry during the phone screens like http://www.tekrevue.com/wp-content/uploads/2013/09/20130923_ios7emergencycallfla w.jpg (left side) and http://i.i.cbsi.com/cnwk.1d/i/tim2/2013/09/20/ChangingYourTheme.png ... You can see there are background images that got blurred out.

  • What are the non-obvious side-effects of using $psdefaultparametervalues.add("ft:wrap",$True) ?

    I'm thinking about dropping these two lines into my profile.ps1 script:
    $psdefaultparametervalues.add("ft:wrap",$True)
    $psdefaultparametervalues.add("ft:auto",$True)
    Are there any adverse side-effects that I will suffer after I do that?
    I know that I'll have to do explicit overrides to those switch values to Format-Table if I don't want those defaults.

    One thing I can think of is if you use -Property * to list everything, it has the potential to leave out columns if the properties are too long.
    Try this first:
    gci | Select -first 1 | FT *
    Then this:
    gci | Select -first 1 | FT * -auto -wrap
    Besides that , I can't really think of anything else; perhaps others can think of things.
    Boe Prox
    Blog |
    Twitter
    PoshWSUS |
    PoshPAIG | PoshChat |
    PoshEventUI
    PowerShell Deep Dives Book

  • Is there a genuine IPad anti glare screen to reduce the reflection/mirror effect when using outdoors?

    The reflection in the IPad 4th generation retina screen when using outdoors or in bright light is very distracting. You look at yourself! Especially if using the pad on your knees.
    I have fitted the excellent Moshi clear protection screen, but this does not reduce the reflection. Amazon sell an anti glare screen for the IPad 2. Anyone found one that really works, or is this something we must put up with.

    Linehill again.  It seems that many users find the same problem, but no one has the answer! I have been experimenting with some ideas and have found wearing a black or very dark shirt makes a huge improvement if you are sitting down and hold the IPad on your thighs. Try it!

  • RIPPLE EFFECT when using mouse to click on scroll bar and scroll

    Has anyone else had this problem? I have tried 4 new 24" iMac's and ALL FOUR do this! When you click on the scroll bar and scroll down or up, there is a definite "ripple" in the window of what you are looking at. It's as if you put a steel rod under a sheet and pulled it up and down. It only happens when using the mouse to click and scroll. Not with the track ball, not with the arrows, not with the keyboard. I updated Safari, tried using Firefox instead, installed all the OS updates, but it still happens. So far no one in Support has a clue. The display models at the stores didn't do it, but my guess is they are from an older shipment...so maybe this is an anomaly with imac's shipped after April 10.
    Try it on your computer and see if it happens. If so, we need to all let Apple know there needs to be a fix.

    HI,
    Quit Safari.
    Go here: MacintoshHD/Library/Preferences and locate this file.
    com.apple.windowserver.plist
    Drag that file to the Desktop. Launch Safari and see if the scroll functions as it should. If it's ok, drag that file to the trash, empty the Trash and restart your Mac.
    Carolyn

  • Do not use the Megaphone effect when using external amp and speakers

    Hi guys,
    I just wanted to let you know that I damaged my Yamaha NS10 speakers while I was testing the effect section on garageband with an external mic through my studio amp and the NS10 studio monitors. When I switched to the Megaphone effect to test it I received such a high frequency signal that it killed my NS10 tweeters. It is very frustrating and I had never really any issues in the past with my monitors.
    I am just posting this topic here to warn you guys, just in case you are trying the same thing. It cost me 250 dollar to replace the tweeters so you better test the effect section of garageband on a very low level or even use your old headphones before you plug your mac to an external amp and speaker set up.
    Good luck,
    Martin

    Sorry to hear about those blown tweeters.
    If it'll help, once you establish a microphone setup using the dropdowns in the lower right-hand corner of the browse window, there are three monitor options: Off, On, & On (no feedback protection).
    Knowing this, the latter may have been the unbeknownst destructive culprit.

  • Strange Effects When Using Erase & Clone Tools In CS4

    I recently upgraded from Elements 8 to CS4 and I've noticed that I have started getting strange effects with both the erase and clone tools. When I have been working with either of these tools for a while I suddenly find that left clicking the mous will cause a spurious reaction in another part of my image. The erase tool erases strips and the clone tool clones other colours and areas. I suspect that it might be due to the amount of memory I'm using but advice would be appreciated. I am running Windows 7 and  I have 4.00GB of physical memory and 11.8GB of virtual memory.
    Looking forward to suggestions.
    Ward1941UK

    I've found the solution to the problem, although it doesn't really please me because I've had to sacrifice the number of history states I can keep. I have reduced the number to 15 from 20 and the problem has gone away, which indicates that it's a memory problem. I'm going to slowly increase the number of states until the problem re-appears.
    Ward1941uk

  • Run a client-side program when using web-enabled forms(host command)

    I am trying to run a local program on my windows machine when i press a button on the oracle web form SCAN[Host('C:\scktscan.exe')]. It trys to execute the program on the server machine and not the client machine. The button will work when forms are run in client-server mode. How can i get the button to access a program on the client machine when the forms are run on the web?

    In order to execute a program at the client pc, you must implement a java bean.
    Have a look at the demos extension pack 1 (http://otn.oracle.com/sample_code/products/forms/content.html)
    It explains also how to implement this in your own application.

  • Frozen right-side screen when using "mail"

    Dear reader
    1) A new incoming mail summary appears, as usual, on the left part of your iPad screen;
    2) As you finger-activate it, it seems to execute a reading procees, as you would expect;
    3) However, the right side of your iPad screen does not show the new message contents;
    4) Instead, the right side of your iPad screen remains "frozen", showing photos from an old
        previous message.  The "photos" resist any attempt to move them...
    Thank you,
    Thierry

    Try quitting the app and the restart the iPad.
    Go to the home screen first by tapping the home button. Quit mail by double tapping the home button and the task bar will appear with all of your recent/open apps displayed at the bottom. Tap and hold down on the mail icon until it begins to wiggle. Tap the minus sign in the upper left corner to close the apps. Restart the iPad.
    Restart the iPad by holding down on the sleep button until the red slider appears and then slide to shut off. To power up hold the sleep button until the Apple logo appears and let go of the button.
    If that doesn't work, rest the iPad.
    Reset the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons.

  • Memory Leak for Graphics2D.drawString?

    Hi, all!!
    I am a Java Programmer who is experienced in Swing application on a windows platform.
    I have developed a code snipplet to print out to use Graphics2D.drawString method.
    Then, I have encountered the performance degrade that the number of objects are created per call for the method.
    It seems that there is a difference among JDKs.
    When such a method is called, the number of objects are created is the followings
    Java1.4 | 138
    Java5 | 946
    Java6 | 1217
    Is this a known bug that JDK has since JDK has changed graphically from Tiger?
    or is it related to memory leak?
    Thank you in advance
    Edited by: Yuichi_Yamada on Jun 30, 2008 5:31 AM

    Yuichi_Yamada wrote:
    Is there a noticeable performance degradation in your application (from the user's perspective?)Compared to Java1.4, it takes 4 times longer to finish print-outs for large volume of data.Please post the example you're benchmarking. I wrote up a quick little micro-benchmark (I know I know, not a 100% accurate benchmark, but just as a quick test), and could not reproduce the performance degradation time-wise (I didn't test memory usage). In fact, with this benchmark, it appears that 1.6 is around 3x faster with Graphics#drawString() than 1.4:
    Printing "Hello, world!" 500,000 times (approximate average of 10 runs):
    1.4 - 5600ms
    1.5 - 2300ms
    1.6 - 1920ms
    Printing "Hello world!Hello world!Hello world!Hello world!Hello world!Hello world!Hello world!Hello world!Hello world!Hello world!" 500,000 times) (approximate average of 10 runs):
    1.4 - 30833ms
    1.6 - 8844ms
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import javax.swing.*;
    public class DrawStringMicroBenchmark extends JFrame {
         private BufferedImage bi;
         private JTextField toPaintField;
         private SpinnerNumberModel iterModel;
         private JTextArea resultArea;
         public DrawStringMicroBenchmark() {
              bi = new BufferedImage(300,300, BufferedImage.TYPE_INT_RGB);
              JPanel cp = new JPanel(new BorderLayout());
              JPanel dataPanel = createDataPanel();
              cp.add(dataPanel, BorderLayout.NORTH);
              JPanel buttonPanel = new JPanel();
              JButton b = new JButton("Repaint");
              b.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        runTest();
              buttonPanel.add(b);
              cp.add(buttonPanel, BorderLayout.SOUTH);
              setContentPane(cp);
              setTitle("Graphics2D#drawString() Micro Benchmark");
              setDefaultCloseOperation(EXIT_ON_CLOSE);
              pack();
         private JPanel createDataPanel() {
              JPanel dataPanel = new JPanel();
              dataPanel.setLayout(new BoxLayout(dataPanel, BoxLayout.Y_AXIS));
              dataPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
              toPaintField = new JTextField("Hello world!", 30);
              dataPanel.add(createLabeledItem("String to paint: ", toPaintField));
              JSpinner iterSpinner = createIterSpinner();
              iterModel = (SpinnerNumberModel)iterSpinner.getModel();
              dataPanel.add(createLabeledItem("Iterations: ", iterSpinner));
              resultArea = new JTextArea(5, 30);
              resultArea.setEnabled(false);
              resultArea.setEditable(false);
              dataPanel.add(createLabeledItem("Result: ", new JScrollPane(resultArea)));
              dataPanel.add(Box.createVerticalGlue());
              return dataPanel;
         private JPanel createLabeledItem(String label, JComponent item) {
              JPanel temp = new JPanel(new BorderLayout());
              temp.add(new JLabel(label), BorderLayout.LINE_START);
              temp.add(item);
              return temp;
         private JSpinner createIterSpinner() {
              SpinnerModel model = new SpinnerNumberModel(50000, 1,Integer.MAX_VALUE, 1000);
              return new JSpinner(model);
         private void runTest() {
              String text = toPaintField.getText();
              int iter = ((Integer)iterModel.getValue()).intValue();
              Graphics2D g2d = bi.createGraphics();
              long start = System.currentTimeMillis();
              for (int i=0; i<iter; i++) {
                   g2d.drawString(text, 30, 30);
              long time = System.currentTimeMillis() - start;
              resultArea.append(iter+ " iterations: " + time + " ms\n");
         public static void main(String[] args) {
              SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                        new DrawStringMicroBenchmark().setVisible(true);
    }

  • Dropdownlist in DataGrid - strange side effect

    I am implementing a dropdownlist as a custom renderer in the Spark DataGrid. The following code will create a negative side effect: When I drop the control down to select an item it will take two clicks for the control to close and show the selected item. Here is the code:
    private function onDataChange(event:Event):void
                   Grid(owner).selectedItem[column.dataField] = selectedItem[column.dataField];
    Any idea what that might be?
    Thanks

    In stepping through the code I think I have identified where the problem is, but don't have a solution. It seems that the default preallocation size is being used, rather than taking the value configured in the TopLink mapping file. When I set the preallocation size in the Java code at runtime the problem goes away.
    But, this only provides me with a work-around. I would like to have TopLink read the mapping file and use what has been configured. Here is a snippet of my code for setting up the TopLink connections:
         login = new DatabaseLogin();
         DataSource dataSource = // get the configured datasource
         Connector connector = new JNDIConnector(dataSource);
         login.setConnector(connector);
         login.usePlatform(new Oracle10Platform());
         login.useNativeSQL();
         login.useNativeSequencing();
         // Would like to avoid doing the following
         //login.getDefaultSequence().setPreallocationSize(5);

  • Negative effects by using DBMS_REDEFINITION package

    Hello everybody,
    I am looking for all 'bad' side effects of using the package.
    I am in project where the definition of tables changes.
    Sometimes a column needs to be placed in the middle of the table.
    Up to now there are scripts which doing a lot of drops of columns, updates, add adds again.
    My idea was to use the package, which I could test successfully.
    Now I learned, that the grants to the table are lost.
    What else should be concerned by using the package?
    Thanks

    Hi,
    Sometimes a column needs to be placed in the middle of the table.hmm and why do you need some redefinition/reorg for the table - just put the columns on the right place in the select statement?
    Now I learned, that the grants to the table are lost.hmm not "really"... have a look at the procedure "COPY_TABLE_DEPENDENTS".
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_redefi.htm#sthref5656
    -> This subprogram is used to clone the dependent objects like grants, triggers, constraints and privileges from the table being redefined to the interim table (which represents the post-redefinition table).
    Side effects:
    You need to create/rebuild the indexes.. because of the rowids change.
    Btw. your scenario seems a little bit "strange" to me...
    Regards
    Stefan

  • Switching from HTTP to HTTPS - adverse side effects???

    Hi everybody,
    what are the possible adverse side effects when changing from HTTP to HTTPS? 
    I could imagine that previously saved web bookmarks would not work, correct?
    Links saved in roles will have to be adjusted in roles, correct?
    Anything else?
    Does anybody have knowledge/experience in this area and how do you recommend to proceed when switching a productive system from HTTP to HTTPS?
    Martin

    The web bookmarks stored on IE browser will still point to the HTTP service, not HTTPS, you will have to make the changes manually.
    The URLS for BW Reports are generated dynamically, you should be able to maintain an entry in table HTTPURLLOC and get this switched to HTTPS. see OSS note 805344 for the same.
    Thanks.

  • Side effects of the /$sync transaction

    Hi!
    Does anyone know is there any side effects of using the transaction code /$sync, which is cleaning up all buffers?
    Personally I'm using it to refresh an ALV table, if it's structure was modified.
    But it is applied only for my session's buffers and it will not harm other people and will not kick out other people from the SAP system.
    Am I right?
    Thank you
    Tamá

    It will not kick out other people, but it does clear ALL buffers, and not only yours. Therefore you should not do it yourself, but rather ask some people from basis if you can and may do it or let them do it.
    help.sap.com:
    command $SYNC to reset all the SAP buffers on the application server. These commands only affect the buffers of the application server on which the commands are entered. The buffers of the other application servers in the network are not affected.
    Using the commands $TAB and $SYNC places an extremely large load on the system. In large systems, it could take up to one hour (depending on the access profile) for the buffer load to return to its original state. System performance is greatly impeded during this time.
    Edited by: Micky Oestreich on Apr 18, 2008 10:39 AM

Maybe you are looking for