Component resize, paint and AffineTransform

Hello,
I am resizing a JInternalFrame that contains a JPanel.
When I call:
MyJPanel.repaint();The paint function gets the dimensions of the JPanel
using getWidth() and getHeight(), once, at the start of the
paint function. The function then proceeds to plot some lines and
points on a graph. Everything appears to work fine for lines and points (ie: drawOval).
The function then goes on to draw some text for the axes of the graph. The Y axis
text plots fine. The X axis text is rotated using AffineTransform and plots intermittently
with the correct and incorrect position.
Calling repaint() for the JPanel, without resizing,
everything renders in the proper place
via the overridden paint() procedure for that panel.
When I resize the JInternalFrame, thus causing the
JPanel to also automatically resize and repaint, the JPanel
paints all lines and points in the correct locations
with respect to the bounds of the JPanel. The
Y axis text, drawn using drawText() plots in the correct place.
The X axis text then plots in the wrong place after AffineTransform
positioning in a location that would indicate it is transforming based on the
coordinate system of the JInternalFrame rather than the JPanel (??).
To create the text transform I am calling the following function:
public void drawRotatedText(Graphics g, String text, int xoff, int yoff, double angle_degrees){
                    Graphics2D g2d=(Graphics2D)g;
                    AffineTransform old_at=((Graphics2D)g).getTransform();
                    AffineTransform at = new AffineTransform(old_at);
                    at.setToTranslation(xoff, yoff);
                    at.rotate((angle_degrees/360.0)*Math.PI*2.0);
                    g2d.setTransform(at);
                    g2d.drawString(text, 0, 0);
                    g2d.setTransform(old_at);
                }The parameter Graphics g is the Graphics passed from public void MyJPanel.paint(Graphics g) .
Why would AffineTransform get confused regarding which component the Graphics is coming from?
More importantly, how can I avoid the problem?
Thanks,
P

>
To create the text transform I am calling the following function:
public void drawRotatedText(Graphics g, String text, int xoff, int yoff, double angle_degrees){
Graphics2D g2d=(Graphics2D)g;
AffineTransform old_at=((Graphics2D)g).getTransform();
AffineTransform at = new AffineTransform(old_at);
at.setToTranslation(xoff, yoff);
at.rotate((angle_degrees/360.0)*Math.PI*2.0);
g2d.setTransform(at);
g2d.drawString(text, 0, 0);
g2d.setTransform(old_at);
The problem is with the use of at.setToTranslation(xoff, yoff); instead of at.translate(xoff, yoff).
After changing that the problem cleared up.
P

Similar Messages

  • Component resizing problem in Vbox

    Hi.. I am facing a peculiar problem.. I have a vbox which contains 5 components, each of which has a line graph and a legend.. But all of them need not be visible at a time.. It depends on the number of parameters returned from a webservice call... so at a time 1-5 of such components maybe visible... i do this by setting includeInLayout and visible to false..
    Each of the components have height and width set to 100%. So I expect all the components which have includeinlayout and visible set to true to be equal in size... But if initially only one of the component is visible and then i want to show 2 components by setting these properties, the component which was visible initially is not resizing.. It is staying the same size as before making the second component visible... second component is getting correct size (half of the size of the VBox)..... Am i doing something wrong here? Can some component not reduce in size if another child added/included in layout of its parent?
    Thanks in advance for your help!

    Hi Philip,
    This is my vbox declaration. Trendline has a linechart and a legend
    <mx:VBox id="chartsContainer" width="100%" height="100%" verticalScrollPolicy="auto">
       <chart:TrendLine id="defaultTrendLineChart" width="100%" height="100%" includeInLayout="true" visible="true"/>
       <chart:TrendLine id="trendChart1" width="100%" height="100%" includeInLayout="false" visible="false"/>
       <chart:TrendLine id="trendChart2" width="100%" height="100%" includeInLayout="false" visible="false"/>
    </mx:VBox>
    And here is the code where i selectively include various charts in the display
    var count:int = 0;
    for (var parameterType:String in parameterTable)
       var trendLineChart:TrendLine = trendChartArray[count++];                                                       
       trendLineChart.includeInLayout = true;
       trendLineChart.visible = true;
       trendLineChart.Initialize();
       trendLineChart.SetView(bIsChartView);                       
       trendLineChart.LoadChart(dataProvider, parameterType, parameterTable[parameterType]);
    I have stored all the children of the vbox in an array for easy fetching
    var trendChartArray:Array = [defaultTrendLineChart, trendChart1, trendChart2];
    parameterTable is a Dictionary in which number of parametertypes can vary from 1 to 3 depending on the result of a webservice call. The problem is that if initially i am showing only one chart and then i have to show 2 charts, the first chart's size is not getting reduced. But the second chart added is getting correct size.
    Thanks a lot for your response.

  • Component resizing behaviour when maximized

    I am wanting to change the behaviour when the main frame is re-sized that only one Jlist in a component consiting of multiple JLists is the only component resized.
    This is currently occuring, however it is the last JList, i wish to be able to nominate the JList that will be resized.
    i.e. the "Name" JList, no the "Up Rate" Jlist.
    This is the gui non-maximized:
    http://img225.imageshack.us/img225/5061/guinormal8xd.png
    This is the gui maximized as is:
    http://img225.imageshack.us/img225/9296/guimaximised5tb.png
    This is the gui as i would like it:
    http://img215.imageshack.us/img215/8238/guimaximised11el.png
    Can anyone give me a few pointers as to how to achieve this?

    [url http://java.sun.com/docs/books/tutorial/uiswing/layout/visual.html]How to Use Layout Managers
    For example when using a BorderLayout. You could add one list to the "WEST" and one to the "CENTER". As the frame is resized the available space will be added (or removed) from the component in the center.
    Or, I believe a GridBadLayout has weightX paramenter which allows you to specify which component gets extra space when the frame is resized.

  • Generalized Component Resizing

    Hey people,
    I wrote a "Component Resizer" which takes care of resizing components. Any component as opposed to just a window or a dialog.
    One problem I noticed while resizing dialogs for example was that when I resize the dialog, the internal panes do not get adjust themselves to the new contained size. Now this happens even if I am using say GridBagLayout or GridLayout.
    Another problem I noticed is that then a component inside a container is resized, the new size is retained until the parent container for this component itself is resized. Then it goes back to its original size. I guess this is because of the layout manager but then, this happens even when I use null layout. I have posted the code here (it's really long).
    Any suggestions?
    thanx,
    -vijai.
    Main resize handler:
    * Copyright (c) 2004,
    * Vijayaraghavan Kalyanapasupathy
    * [email protected]
    * See accompanying project license for license terms and agreement.
    * The use of the intellectual property contained herein is subject
    * to the terms of the license agreement. If no license agreement
    * can be found at the locations from where you obtained this
    * sofwtare/file/code fragment contact the author for the license.
    * Contributors: Vijayaraghavan Kalyanapasupathy
    * Created     : 4:03:42 AM, Dec 2, 2004
    * Project     : SwingComponents
    package org.swingcomponents.components;
    import java.awt.Component;
    import java.awt.Cursor;
    import java.awt.Dimension;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.awt.event.MouseMotionListener;
    import javax.swing.JComponent;
    import org.apache.log4j.Logger;
    /**<p>
    * A configurable listener which can resize any component that can generate mouse drag and mouse events.
    * </p>
    * <p>
    * General model for this is that <br/>
    * <ul>
    *  <li> On demand resizing region margin
    *  <li> On demand resizing directions modification
    * </ul>
    * </p>
    * @author Vijayaraghavan Kalyanapasupathy
    public class ComponentResizer extends    MouseAdapter
                                  implements MouseListener,
                                             MouseMotionListener {
         static final int DEFAULT_MARGIN = 8;
          * The sensitivity on the left side within which a mouse drag is interpreted as a resize action.
         static int c_leftmargin   = DEFAULT_MARGIN;
          * The sensitivity on the right side within which a mouse drag is interpreted as a resize action.
         static int c_rightmargin  = DEFAULT_MARGIN;
          * The sensitivity on the top within which a mouse drag is interpreted as a resize action.
         static int c_topmargin    = DEFAULT_MARGIN;
          * The sensitivity on the bottom within which a mouse drag is interpreted as a resize action.
         static int c_bottommargin = DEFAULT_MARGIN;
          * Sets the default margins for all newly generated resizers.
          * @param p_top The new top margin
          * @param p_left The new left side margin
          * @param p_bottom The new bottom margin
          * @param p_right The new right side margin
         public static void setDefaultMargins(int p_top,int p_left,int p_bottom,int p_right) {
              c_logger.debug("Attempting to change application wide margins to: ("+p_top+","+p_left+","+p_bottom+","+p_right+")");
              c_leftmargin   = p_left > 0 ? p_left : c_leftmargin;
              c_rightmargin  = p_right > 0 ? p_right : c_rightmargin;
              c_topmargin    = p_top > 0 ? p_top : c_topmargin;
              c_bottommargin = p_bottom > 0 ? p_bottom : c_bottommargin;
              c_logger.debug("Changed application wide margins to: ("+c_topmargin+","+c_leftmargin+","+c_bottommargin+","+c_rightmargin+")");
          * Retrieves the default application wide left margin used for newly created resizers.
          * @return The default left margin
         public static int getDefaultLeftMargin() {
              return c_leftmargin;
          * Retrieves the default application wide top margin used for newly created resizers.
          * @return The default top margin
         public static int getDefaultTopMargin() {
              return c_topmargin;
          * Retrieves the default application wide right margin used for newly created resizers.
          * @return The default right margin
         public static int getDefaultRightMargin() {
              return c_rightmargin;
          * Retrieves the default application wide bottom margin used for newly created resizers.
          * @return The default bottom margin
         public static int getDefaultBottomMargin() {
              return c_bottommargin;     
          * The standard log4j logger that all instances of this class use
          * to log messages.
         static Logger c_logger = Logger.getLogger(ComponentResizer.class);
         /* The cursors for each direction */
         /** The top resize cursor */
         static final Cursor c_topcursor         = Cursor.getPredefinedCursor(Cursor.N_RESIZE_CURSOR);
         /** The left side resize cursor */
         static final Cursor c_leftcursor        = Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR);
         /** The right side resize cursor */
         static final Cursor c_rightcursor       = Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR);
         /** The bottom resize cursor */
         static final Cursor c_bottomcursor      = Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR);
         /** The topleft resize cursor */
         static final Cursor c_topleftcursor     = Cursor.getPredefinedCursor(Cursor.NW_RESIZE_CURSOR);
         /** The topright resize cursor */
         static final Cursor c_toprightcursor    = Cursor.getPredefinedCursor(Cursor.NE_RESIZE_CURSOR);
         /** The bottomleft resize cursor */
         static final Cursor c_bottomleftcursor  = Cursor.getPredefinedCursor(Cursor.SW_RESIZE_CURSOR);
         /** The bottomright resize cursor */
         static final Cursor c_bottomrightcursor = Cursor.getPredefinedCursor(Cursor.SE_RESIZE_CURSOR);
          * Method that performs initialization stuff.
         protected void InitializeResizer() {
              c_logger.debug("Initializing resizer: ");
              m_leftmargin   = c_leftmargin;
              m_rightmargin  = c_rightmargin;
              m_bottommargin = c_bottommargin;
              m_topmargin    = c_topmargin;
              c_logger.debug("Initialized default margins from application wide settings: ("+m_topmargin+","+m_leftmargin+","+m_bottommargin+","+m_rightmargin+")");
              c_logger.debug("Setting default resize options: ");
              m_allowTopLeftResize    = m_allowTopRightResize    = true;
              m_allowBottomLeftResize = m_allowBottomRightResize = true;
              m_allowLeftResize       = m_allowRightResize       = true;
              m_allowTopResize        = m_allowBottomResize      = true;
              c_logger.debug("Getting component default cursor: ");
              m_componentcursor = m_component.getCursor();
         /** The resizer specific left side margin */
         int m_leftmargin;
         /** The resizer specific top margin */
         int m_topmargin;
         /** The resizer specific right side margin */
         int m_rightmargin;
         /** The resizer specific bottom margin */
         int m_bottommargin;
         /** Indicates that top side resizing should be allowed. */
         boolean m_allowTopResize;
         /** Indicates that bottom side resizing should be allowed. */
         boolean m_allowBottomResize;
         /** Indicates that left side resizing should be allowed. */
         boolean m_allowLeftResize;
         /** Indicates that right side resizing should be allowed. */
         boolean m_allowRightResize;
         /** Indicates that top left resizing should be allowed. */
         boolean m_allowTopLeftResize;
         /** Indicates that top right resizing should be allowed. */
         boolean m_allowTopRightResize;
         /** Indicates that bottom left resizing should be allowed. */
         boolean m_allowBottomLeftResize;
         /** Indicates that bottom right resizing should be allowed. */
         boolean m_allowBottomRightResize;
         /** The component that we are focussing on */
         Component m_component = null;
         /** The layout key for the component */
         String m_layoutkey = null;
          * Creates a new component resizer that attaches itself as a mouse listener and
          * as a mouse motion listener to the given component.
          * @param p_component The component to attach the listener to.
          * @param p_layoutkey The key used in the layout manager of the component's parent for this object.
         public ComponentResizer(Component p_component,String p_layoutkey) {
              super();
              m_component = p_component;
              m_layoutkey = p_layoutkey;
              if(m_component != null) {
                   c_logger.debug("Initializing resizer for: "+m_component);
                   InitializeResizer();
                   m_component.getToolkit().setDynamicLayout(true);
                   m_component.addMouseListener(this);
                   m_component.addMouseMotionListener(this);
              }else {
                   c_logger.warn("Component is null: ");
          * Sets the resizer specific bottom margin.
          * @param p_bottommargin The bottommargin to set.
         public void setBottomMargin(int p_bottommargin) {
              c_logger.debug("Attempting to set top margin to: "+p_bottommargin);
              m_bottommargin = p_bottommargin > 0 ? p_bottommargin : m_bottommargin;
              c_logger.debug("Bottom margin set to: "+m_bottommargin);
          * Sets the resizer specific left side margin.
          * @param p_leftmargin The leftmargin to set.
         public void setLeftMargin(int p_leftmargin) {
              c_logger.debug("Attempting to set left margin to: "+p_leftmargin);
              m_leftmargin = p_leftmargin > 0 ? p_leftmargin : m_leftmargin;
              c_logger.debug("Left margin set to: "+m_leftmargin);
          * Sets the resizer specific right side margin.
          * @param p_rightmargin The rightmargin to set.
         public void setRightMargin(int p_rightmargin) {
              c_logger.debug("Attempting to set right margin to: "+p_rightmargin);
              m_rightmargin = p_rightmargin > 0 ? p_rightmargin : m_rightmargin;
              c_logger.debug("Right margin set to: "+m_rightmargin);
          * Sets the resizer specific top margin.
          * @param p_topmargin The topmargin to set.
         public void setTopMargin(int p_topmargin) {
              c_logger.debug("Attempting to set top margin to: "+p_topmargin);
              m_topmargin = p_topmargin > 0 ? p_topmargin : m_topmargin;
              c_logger.debug("Top margin set to: "+m_topmargin);
          * Returns the bottom margin.
          * @return Returns the bottommargin.
         public int getBottomMargin() {
              return m_bottommargin;
          * Returns the left margin.
          * @return Returns the leftmargin.
         public int getLeftMargin() {
              return m_leftmargin;
          * Returns the right margin.
          * @return Returns the rightmargin.
         public int getRightMargin() {
              return m_rightmargin;
          * Returns the top margin.
          * @return Returns the topmargin.
         public int getTopMargin() {
              return m_topmargin;
          * @return Returns the allowBottomLeftResize.
         public boolean isAllowBottomLeftResize() {
              return m_allowBottomLeftResize;
          * @return Returns the allowBottomResize.
         public boolean isAllowBottomResize() {
              return m_allowBottomResize;
          * @return Returns the allowBottomRightResize.
         public boolean isAllowBottomRightResize() {
              return m_allowBottomRightResize;
          * @return Returns the allowLeftResize.
         public boolean isAllowLeftResize() {
              return m_allowLeftResize;
          * @return Returns the allowRightResize.
         public boolean isAllowRightResize() {
              return m_allowRightResize;
          * @return Returns the allowTopLeftResize.
         public boolean isAllowTopLeftResize() {
              return m_allowTopLeftResize;
          * @return Returns the allowTopResize.
         public boolean isAllowTopResize() {
              return m_allowTopResize;
          * @return Returns the allowTopRightResize.
         public boolean isAllowTopRightResize() {
              return m_allowTopRightResize;
          * @param p_allowBottomLeftResize The allowBottomLeftResize to set.
         public void setAllowBottomLeftResize(boolean p_allowBottomLeftResize) {
              c_logger.debug("Setting bottom left resizing to: "+p_allowBottomLeftResize);
              m_allowBottomLeftResize = p_allowBottomLeftResize;
          * @param p_allowBottomResize The allowBottomResize to set.
         public void setAllowBottomResize(boolean p_allowBottomResize) {
              c_logger.debug("Setting bottom resizing to: "+p_allowBottomResize);
              m_allowBottomResize = p_allowBottomResize;
          * @param p_allowBottomRightResize The allowBottomRightResize to set.
         public void setAllowBottomRightResize(boolean p_allowBottomRightResize) {
              c_logger.debug("Setting bottom right resizing to: "+p_allowBottomRightResize);
              m_allowBottomRightResize = p_allowBottomRightResize;
          * @param p_allowLeftResize The allowLeftResize to set.
         public void setAllowLeftResize(boolean p_allowLeftResize) {
              c_logger.debug("Setting left resizing to: "+p_allowLeftResize);
              m_allowLeftResize = p_allowLeftResize;
          * @param p_allowRightResize The allowRightResize to set.
         public void setAllowRightResize(boolean p_allowRightResize) {
              c_logger.debug("Setting right side resizing to: "+p_allowRightResize);
              m_allowRightResize = p_allowRightResize;
          * @param p_allowTopLeftResize The allowTopLeftResize to set.
         public void setAllowTopLeftResize(boolean p_allowTopLeftResize) {
              c_logger.debug("Setting top left resizing to: "+p_allowTopLeftResize);
              m_allowTopLeftResize = p_allowTopLeftResize;
          * @param p_allowTopResize The allowTopResize to set.
         public void setAllowTopResize(boolean p_allowTopResize) {
              c_logger.debug("Setting top side resizing to: "+p_allowTopResize);
              m_allowTopResize = p_allowTopResize;
          * @param p_allowTopRightResize The allowTopRightResize to set.
         public void setAllowTopRightResize(boolean p_allowTopRightResize) {
              c_logger.debug("Setting top right resizing to: "+p_allowTopRightResize);
              m_allowTopRightResize = p_allowTopRightResize;
          * Following are the methods that do all the real stuff.
         /* We define constants that allow us to determine where the cursor is. */
         static final int TOP         = 0x0001;
         static final int BOTTOM      = 0x0002;
         static final int LEFT        = 0x0100;
         static final int RIGHT       = 0x0200;
         static final int TOPLEFT     = 0x0101;
         static final int TOPRIGHT    = 0x0201;
         static final int BOTTOMLEFT  = 0x0102;
         static final int BOTTOMRIGHT = 0x0202;
         static final int UNKNOWN     = 0x0000;
         protected int whereX(int p_x) {
              // check if on left side
              if(p_x >= 0 &&
                 p_x <= m_leftmargin) {
                   c_logger.debug("Cursor is on LEFT");
                   return LEFT;
              // check if on right side
              if(p_x <= m_component.getWidth() &&
                 p_x >= m_component.getWidth()-m_rightmargin) {
                   c_logger.debug("Cursor is on RIGHT");
                   return RIGHT;
              return UNKNOWN;
         protected int whereY(int p_y) {
              // check if on top side
              if(p_y >= 0 &&
                 p_y <= m_topmargin) {
                   c_logger.debug("Cursor is on TOP");
                   return TOP;
              // check if on bottom side
              if(p_y <= m_component.getHeight() &&
                 p_y >= m_component.getHeight()-m_bottommargin) {
                   c_logger.debug("Cursor is on BOTTOM");
                   return BOTTOM;
              return UNKNOWN;
         protected int where(int p_x,int p_y) {
              c_logger.debug("Determining pointer location: ");
              int l_composite = (whereX(p_x) | whereY(p_y));
              switch(l_composite) {
                   case LEFT:
                        c_logger.debug("Left");
                        break;
                   case RIGHT:
                        c_logger.debug("Right");
                        break;
                   case BOTTOM:
                        c_logger.debug("Bottom");
                        break;
                   case TOP:
                        c_logger.debug("Top");
                        break;
                   case TOPLEFT:
                        c_logger.debug("Top left");
                        break;
                   case TOPRIGHT:
                        c_logger.debug("Top right");
                        break;
                   case BOTTOMLEFT:
                        c_logger.debug("Bottom left");
                        break;
                   case BOTTOMRIGHT:
                        c_logger.debug("Bottom right");
                        break;
              return l_composite;
          * The component's default cursor.
         Cursor m_componentcursor;
         boolean m_resizingcursor;
         boolean m_dragready;
         protected void changeCursor(int p_where) {
              c_logger.debug("Changing cursor: ");
              m_resizingcursor = true;
              switch(p_where) {
                   case LEFT:
                        if(m_allowLeftResize) {
                             m_component.setCursor(c_leftcursor);
                        }else {
                             m_resizingcursor = false;
                        break;
                   case RIGHT:
                        if(m_allowRightResize) {
                             m_component.setCursor(c_rightcursor);
                        }else {
                             m_resizingcursor = false;
                        break;
                   case TOP:
                        if(m_allowTopResize) {
                             m_component.setCursor(c_topcursor);
                        }else {
                             m_resizingcursor = false;
                        break;
                   case BOTTOM:
                        if(m_allowBottomResize) {
                             m_component.setCursor(c_bottomcursor);
                        }else {
                             m_resizingcursor = false;
                        break;
                   case TOPLEFT:
                        if(m_allowTopLeftResize) {
                             m_component.setCursor(c_topleftcursor);
                        }else {
                             m_resizingcursor = false;
                        break;
                   case TOPRIGHT:
                        if(m_allowTopRightResize) {
                             m_component.setCursor(c_toprightcursor);
                        }else {
                             m_resizingcursor = false;
                        break;
                   case BOTTOMLEFT:
                        if(m_allowBottomLeftResize) {
                             m_component.setCursor(c_bottomleftcursor);
                        }else {
                             m_resizingcursor = false;
                        break;
                   case BOTTOMRIGHT:
                        if(m_allowBottomRightResize) {
                             m_component.setCursor(c_bottomrightcursor);
                        }else {
                             m_resizingcursor = false;
                        break;
                   default:
                        c_logger.debug("Reverting to default component cursor: ");
                        m_resizingcursor = false;
                        m_component.setCursor(m_componentcursor);
                        break;
         protected void modifyBounds(int p_newx,int p_newy,int p_newwidth,int p_newheight) {
              m_component.setBounds(p_newx,p_newy,p_newwidth,p_newheight);
              m_component.setSize(p_newwidth,p_newheight);
              /*if(m_component.getParent() != null) {
                   LayoutManager l_manager = m_component.getParent().getLayout();
                   if(l_manager != null) {
                        l_manager.removeLayoutComponent(m_component);
                        l_manager.addLayoutComponent(m_layoutkey,m_component);
              if(m_component instanceof JComponent) {
                   ((JComponent) m_component).setPreferredSize(new Dimension(p_newwidth,p_newheight));
              m_component.repaint();
         protected void resizeLeft(MouseEvent p_e) {
              c_logger.debug("Resizing left side: ");
              if(p_e.getX() <= m_component.getWidth()-m_leftmargin-m_rightmargin-4) {
                   int l_newx = m_component.getX();
                   int l_newwidth = m_component.getWidth();
                   c_logger.debug("Eligible for leftward resize: ");
                   if(p_e.getX() <= 0) {
                        c_logger.debug("Leftward drag: ");
                        l_newx = p_e.getX()+m_component.getX();
                        l_newwidth = m_component.getWidth()-p_e.getX();
                   }else {
                        c_logger.debug("anti-Leftward drag: ");
                        l_newx = m_component.getX()-p_e.getX();
                        l_newwidth = m_component.getWidth()-p_e.getX();
                   c_logger.debug("Component new X: "+l_newx);
                   c_logger.debug("Component new W: "+l_newwidth);
                   modifyBounds(l_newx,m_component.getY(),l_newwidth,m_component.getHeight());
         protected void resizeBottom(MouseEvent p_e) {
              c_logger.debug("Resizing bottom side: ");
              if(p_e.getY() >= m_topmargin+m_bottommargin+4) {
                   c_logger.debug("Eligible for bottom side resize: ");
                   int l_newheight = p_e.getY();
                   c_logger.debug("Component new H: "+l_newheight);
                   modifyBounds(m_component.getX(),m_component.getY(),m_component.getWidth(),l_newheight);
         protected void resizeRight(MouseEvent p_e) {
              c_logger.debug("Resizing right side: ");
              if(p_e.getX() >= m_leftmargin+m_rightmargin+4) {
                   c_logger.debug("Eligible for right side resize: ");
                   int l_newwidth = p_e.getX();
                   c_logger.debug("Component new W: "+l_newwidth);
                   modifyBounds(m_component.getX(),m_component.getY(),l_newwidth,m_component.getHeight());
         protected void resizeTop(MouseEvent p_e) {
              c_logger.debug("Resizing top side: ");
              if(p_e.getY() <= m_component.getHeight()-m_topmargin-m_bottommargin-4) {
                   int l_newy = m_component.getY();
                   int l_newheight = m_component.getHeight();
                   c_logger.debug("Eligible for top side resize: ");
                   if(p_e.getY() <= 0) {
                        c_logger.debug("Topward drag: ");
                        l_newy = m_component.getY()+p_e.getY();
                        l_newheight = m_component.getHeight()-p_e.getY();
                   }else {
                        c_logger.debug("anti-Topward drag: ");
                        l_newy = m_component.getY()+p_e.getY();
                        l_newheight = m_component.getHeight()-p_e.getY();
                   c_logger.debug("Component new Y: "+l_newy);
                   c_logger.debug("Component new H: "+l_newheight);
                   modifyBounds(m_component.getX(),l_newy,m_component.getWidth(),l_newheight);
         protected void resizeBottomLeft(MouseEvent p_e) {
              c_logger.debug("Resizing southwest...");
              resizeBottom(p_e);
              resizeLeft(p_e);
         protected void resizeBottomRight(MouseEvent p_e) {
              c_logger.debug("Resizing southeast...");
              resizeBottom(p_e);
              resizeRight(p_e);
         protected void resizeTopLeft(MouseEvent p_e) {
              c_logger.debug("Resizing northwest...");
              resizeTop(p_e);
              resizeLeft(p_e);
         protected void resizeTopRight(MouseEvent p_e) {
              c_logger.debug("Resizing northeast...");
              resizeTop(p_e);
              resizeRight(p_e);
         /* (non-Javadoc)
          * @see java.awt.event.MouseMotionListener#mouseDragged(java.awt.event.MouseEvent)
         public void mouseDragged(MouseEvent p_e) {
              c_logger.debug("Dragged at: "+p_e.getX()+","+p_e.getY());
              if(m_resizingcursor) {
                   c_logger.debug("Resizing... ");
                   switch(m_component.getCursor().getType()) {
                        case Cursor.E_RESIZE_CURSOR:
                             resizeRight(p_e);
                             break;
                        case Cursor.SE_RESIZE_CURSOR:
                             resizeBottomRight(p_e);
                             break;
                        case Cursor.N_RESIZE_CURSOR:
                             resizeTop(p_e);
                             break;
                        case Cursor.NE_RESIZE_CURSOR:
                             resizeTopRight(p_e);
                             break;
                        case Cursor.S_RESIZE_CURSOR:
                             resizeBottom(p_e);
                             break;
                        case Cursor.SW_RESIZE_CURSOR:
                             resizeBottomLeft(p_e);
                             break;
                        case Cursor.NW_RESIZE_CURSOR:
                             resizeTopLeft(p_e);
                             break;
                        case Cursor.W_RESIZE_CURSOR:
                             resizeLeft(p_e);
                             break;
         /* (non-Javadoc)
          * @see java.awt.event.MouseMotionListener#mouseMoved(java.awt.event.MouseEvent)
         public void mouseMoved(MouseEvent p_e) {
              c_logger.debug("Moved at: "+p_e.getX()+","+p_e.getY());
              changeCursor(where(p_e.getX(),p_e.getY()));
         /* (non-Javadoc)
          * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
         public void mouseClicked(MouseEvent p_e) {
              c_logger.debug("Clicked at: "+p_e.getX()+","+p_e.getY());
         /* (non-Javadoc)
          * @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent)
         public void mouseEntered(MouseEvent p_e) {
              c_logger.debug("Entered at: "+p_e.getX()+","+p_e.getY());
         /* (non-Javadoc)
          * @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent)
         public void mouseExited(MouseEvent p_e) {
              c_logger.debug("Exited at: "+p_e.getX()+","+p_e.getY());
              if(!m_dragready) {
                   changeCursor(UNKNOWN);
         /* (non-Javadoc)
          * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
         public void mousePressed(MouseEvent p_e) {
              c_logger.debug("Pressed at: "+p_e.getX()+","+p_e.getY());
              if(m_resizingcursor) {
                   m_dragready = true;
         /* (non-Javadoc)
          * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
         public void mouseReleased(MouseEvent p_e) {
              c_logger.debug("Released at: "+p_e.getX()+","+p_e.getY());
              m_dragready = false;
    }Test file:
    * Copyright (c) 2004,
    * Vijayaraghavan Kalyanapasupathy
    * [email protected]
    * See accompanying project license for license terms and agreement.
    * The use of the intellectual property contained herein is subject
    * to the terms of the license agreement. If no license agreement
    * can be found at the locations from where you obtained this
    * sofwtare/file/code fragment contact the author for the license.
    * Contributors: Vijayaraghavan Kalyanapasupathy
    * Created     : 4:55:08 AM, Dec 2, 2004
    * Project     : SwingComponents
    package org.swingcomponents.tests;
    import java.awt.Color;
    import java.awt.Dimension;
    import javax.swing.JDialog;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JTextArea;
    import javax.swing.border.LineBorder;
    import org.netbeans.lib.awtextra.AbsoluteConstraints;
    import org.netbeans.lib.awtextra.AbsoluteLayout;
    import org.swingcomponents.components.ComponentResizer;
    * @author Vijayaraghavan Kalyanapasupathy
    public class TestComponentResizer {
         public static void testUndecoratedDialog() {
              try {
                   JDialog.setDefaultLookAndFeelDecorated(false);
                   JDialog l_dialog = new JDialog(new JFrame());
                   JDialog.setDefaultLookAndFeelDecorated(true);
                   l_dialog.setUndecorated(true);
                   l_dialog.setLocation(400,500);
                   l_dialog.setSize(300,300);
                   l_dialog.setVisible(true);
                   l_dialog.setDefaultCloseOperation(JDialog.EXIT_ON_CLOSE);
                   l_dialog.setBackground(Color.BLACK);
                   JPanel l_panel = new JPanel();
                   l_panel.setBorder(LineBorder.createGrayLineBorder());
                   l_dialog.getContentPane().add(l_panel);
                   ComponentResizer l_resizer = new ComponentResizer(l_dialog,null);
                   l_dialog.pack();
                   l_dialog.show();
              }catch (Throwable t) {
                   t.printStackTrace(System.err);
         public static void testJTextArea() {
              try {
                   JFrame l_frame = new JFrame("Test DropDownDialog") {
                        public Dimension getPreferredSize() {
                             return new Dimension(800,600);
                   JTextArea l_area = new JTextArea(10,40);
                   ComponentResizer l_resizer = new ComponentResizer(l_area,null);
                   l_frame.getContentPane().setLayout(new AbsoluteLayout());
                   l_frame.getContentPane().add(l_area, new AbsoluteConstraints(300,400,300,300));
                   l_frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                   l_frame.pack();
                   l_frame.show();
              }catch(Throwable t) {
                   t.printStackTrace(System.err);
         public static void main(String[] args) {
              testJTextArea();
              //testUndecoratedDialog();
    }

    Apologies,
    I have left out the AbsoluteLayout and AbsoluteConstraints, but the same effect can supposedly be achieved using null layout and absolute positioning. This doesn't work for me, so if you would like those files (from netBeans) I will post them as well.
    thanx,
    -vijai.

  • First post:  In total desperation...Simple resizing issue and keeping images centered on stage.  Giving a demonoid account for solution :)

    Ok long story short I purchased a fullscreen xml gallery from FlashDen that is supposed to resize.  Here is the link to the demo...
    http://flashden.net/item/xml-resizeable-fullscreen-dark-gallery/full_screen_preview/19966
    Well problem is it only resizes the images based on their width and not their height.  (Panorama would show fine but a tall portrait would just go off the page)  You will notice in that demo how the resizing is fixed to the side of the painting and not the bottom.
    Well, to me this seams useless because I really need every user to be able to see the full pictures no matter what screen resolution they are at and no matter how they adjust their browser window.
    Believe me when I come posting on threads it means I have spend many many hours trying to figure it out myself...In this case I have spent 30 hours trying to solve this in the last two days....Now I am over the deadline I gave to my client/family member and am still at square one basically.
    Thank you so much for any tips/advice/input you can offer.
    Also note I have figured out how to make it so that it fixes to the bottom and thus shows the tall images in full but when I do this it is no longer centered in the page.
    I am really tired and worn out but would love to work with someone's advice to make this a reality.
    Attached is everything you would need.  Please note that by downloading this attachment you are agreeing to only using these files to help out your new friend Sean and would never think about using this for your own project.
    Thanks so much for helping out the new guy.  I will owe you big time!
    Also, Here is the version I am working on...
    http://nasso.us/new/
    It's going to be pretty cool huh?
    Also, in my version on nasso.us..You will notice I got it to almost work for the tall images..Still not there yet...and it all goes off center with that code...To get those resualts though I switched this....
    //determine image size
    resizeImage = function(getResizeClip){
         //eval(getResizeClip);
         stageWidth = Stage.width;
         stageHeight = Stage.height;
         bgWidth = eval(getResizeClip)._width;
         bgHeight = eval(getResizeClip)._height;
         heightRatio = stageWidth/bgWidth;
         widthRatio = stageHeight/bgHeight;
         if(heightRatio<widthRatio){
              eval(getResizeClip)._width = widthRatio*bgWidth;
              eval(getResizeClip)._height = widthRatio*bgHeight;
         }else{
              eval(getResizeClip)._width = heightRatio*bgWidth;
              eval(getResizeClip)._height = heightRatio*bgHeight;
    with this
    //determine image size
    resizeImage = function(getResizeClip){
         //eval(getResizeClip);
         stageWidth = Stage.width;
         stageHeight = Stage.height;
         bgWidth = eval(getResizeClip)._width;
         bgHeight = eval(getResizeClip)._height;
         heightRatio = stageWidth/bgWidth;
         widthRatio = stageHeight/bgHeight;
         if(heightRatio<widthRatio){
              eval(getResizeClip)._width = widthRatio*bgWidth;
              eval(getResizeClip)._height = widthRatio*bgHeight;
         }else{
              eval(getResizeClip)._width = heightRatio*bgWidth;
              eval(getResizeClip)._height = heightRatio*bgHeight;
    THANK YOU THANK YOU THANK YOU

    You are welcome. I'm glad you got it back up.
    (1) You say you did the symbolic link. I will assume this is set correctly; it's very important that it is.
    (2) I don't know what you mean by "Been feeding the [email protected] for several weeks now, 700 emails each day at least." After the initial training period, SpamAssassin doesn't learn from mail it has already processed correctly. At this point, you only need to teach SpamAssassin when it is wrong. [email protected] should only be getting spam that is being passed as clean. Likewise, [email protected] should only be getting legitimate mail that is being flagged as junk. You are redirecting mail to both [email protected] and [email protected] ... right? SpamAssassin needs both.
    (3) Next, as I said before, you need to implement those "Frontline spam defense for Mac OS X Server." Once you have that done and issue "postfix reload" you can look at your SMTP log in Server Admin and watch as Postfix blocks one piece of junk mail after another. It's kind of cool.
    (4) Add some SARE rules:
    Visit http://www.rulesemporium.com/rules.htm and download the following rules:
    70sareadult.cf
    70saregenlsubj0.cf
    70sareheader0.cf
    70sarehtml0.cf
    70sareobfu0.cf
    70sareoem.cf
    70sarespoof.cf
    70sarestocks.cf
    70sareunsub.cf
    72sare_redirectpost
    Visit http://www.rulesemporium.com/other-rules.htm and download the following rules:
    backhair.cf
    bogus-virus-warnings.cf
    chickenpox.cf
    weeds.cf
    Copy these rules to /etc/mail/spamassassin/
    Then stop and restart mail services.
    There are other things you can do, and you'll find differing opinions about such things. In general, I think implementing the "Frontline spam defense for Mac OS X Server" and adding the SARE rules will help a lot. Good luck!

  • What is the difference between paint() and paintComponent()?

    I always confuse by them?
    Thanks

    paintComponent is the method used by Swing components to do the painting necessary for the component. If you are making a custom Swing component, it is recommended that you override paintComponent instead of paint. Non-swing AWT components do not have a paintComponent method.
    A Swing component's default paint() method partitions the painting of a component into separate phases, including painting the component itself, painting the component's border, and finally painting all its children. Overriding paintComponent in a custom Swing component only affects the drawing of the component itself without impacting these other phases of drawing.

  • What's the difference between paint and paintComponent?

    can any body tell me the difference between paint and paintComponent?and when i should use paint and when use paintComponent?
    I know that when I use repaint,it will clear all the objects and then paint again?
    is there a method similar to repaint?
    thanks in advance!

    and when i should use paint and when use paintComponent?Simple answer:
    a) override paint() when doing custom painting on an AWT component
    b) override paintComponent() when doing custom painting on a Swing component
    Detailed answer:
    Read the article on [url http://java.sun.com/products/jfc/tsc/articles/painting/index.html]Painting in AWT and Swing.
    Read the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/14painting/index.html]Custom Painting.

  • Nimbus focus painting and insets

    We are still having this problem - wanted to try again on the queue.
    We have a custom table cell editor component that uses a spinner for the editor component. With Nimbus look and feel, the focus is painted around the outside of the component. However in a table cell, this focus painting (and cooresponding insets) takes up too much space. Is there a way to turn off the focus paining (or control the insets) on Nimbus for this cell editor?
    Edited by: cmildenb on Jul 9, 2012 4:44 PM
    Edited by: cmildenb on Apr 22, 2013 10:41 AM

    Try this.
    JFormattedTextField f =
            ((JSpinner.DefaultEditor) spinner.getEditor()).getTextField();
    f.putClientProperty("Nimbus.Overrides",new UIDefaults());
    f.putClientProperty("Nimbus.Overrides.InheritDefaults",false);This will essentially result in a more basic painter for the painting of the spinner's text field. So no border is painted, nor any focus (though it will still be focusable). You'll still have the nimbus style buttons of the spinner.
    Alternatively you could try a "mini" or "small" spinner.
    spinner.putClientProperty("JComponent.sizeVariant","mini");
    spinner.updateUI();

  • I have Photoshop CS6 Extended Students and Teachers Edition.  When I go into the Filter/Oil paint and try to use Oil paint a notice comes up "This feature requires graphics processor acceleration.  Please check Performance Preferences and verify that "Use

    I have Photoshop CS6 Extended Students and Teachers Edition.  when I go into the Filter/Oil paint and try to use Oil Paint a notice comes up "This feature requires graphics processor acceleration.  Please Check Performance Preferences and verify that "Use Graphics Processor" is enabled.  When I go into Performance Preferences I get a notice "No GPU available with Photoshop Standard.  Is there any way I can add this feature to my Photoshop either by purchasing an addition or downloading something?

    Does you display adapter have a supported  GPU with at least 512MB of Vram? And do you have the latest device drivers install with Open GL support.  Use CS6 menu Help>System Info... use its copy button and paste the information in here.

  • What is the difference between Component,Server,Tool and Software?

    HI,
    What is the difference between Component,Server,Tool and Software?
    SHABEER

    Hi
    Every individual part that constitutes in making an SAP System is called a COMPONENT.e.g DB instance, Java CI, ABAP CI etc
    SERVER is the actual composition of different components of SAP.e.g. a database alongwith can instance would constitue an application server.
    TOOLS are the products from different organisations (SAP or Non SAP) that can be used for different functionalities like keeping a check on jobs, monitoring of the system , e.g Tivoli
    SOFTWARES are a kind of tool that help you to bring up results from the system in a user acceptable format. These are utilities that act as interfaces between the user and the system.
    regards
    Chen

  • Is there a way to minimize packaged links sizes to that of resized dimensions and dpi  InDesign C

    Looking for a way to minimize packaged links sizes to that of resized dimensions and dpi?
    Is this a script? How would I go about finding something like this? What is the best way to
    not duplicate images. Storage is beginning to become a problem!
    Thanks,
    Alex

    Hey Alex,
    I think that a plugin called Link Optimizer is just what you're looking for.
    http://zevrix.com/linkoptimizer.php
    Cheers,
    -Andrew

  • Resizing Image and Not Keep Aspect Ratio

    Is there a free program to resize images and not keep the original aspect ratio?
    I need to resize loads of images to 100x100 pixels and have tried Image well and IResize yet they do not seem to have an option to not keep the original aspect ratio.
    Thank you
    20" Intel 2GHz Core Duo imac, 2GB Ram, 250 GB HD    

    Hi, Downsize does not seem all that great according to reviews. Why not see if you can buy PS E' 3 mac -- maybe ebay/amazon (if I remember I only paid about $70 for PS E3) As PS E4 just came out I'm sure someone has PS E3 for sale. You will then have no problems completing your image resizing.
    2 other questions for you..are you using the Mac side of your intel or Windows?
    if your using the Windows side I can let you have PS 6 (PC) ..freegratus.

  • Non-modal JDialog is not painted and blocks the GUI

    I have developed a GUI that's basically a JFrame with a JDesktopPane.
    The user can, via a menu item, pop up a JDialog that contains some JLists and then select some value from it. Once he/she has done the selection and clicks on OK, the dialog disappears (data processing is then done in the main GUI) and comes back once a specific event has happened. The user then selects other data and so on, until he/she clicks on Cancel, which definitely disposes of the JDialog.
    The graphics of the JDialog are build in the class constructor, which does a pack() but does not make the dialog visible yet. The dialog appears only when doSelection() is called.
         /** Called the first time when user selects the menu item, and then
         when a specific event has happened. */
         public Data[] doSelection() {
              dialog.setVisible(true);
              // ... Code that reacts to user's input. Basically, the ActionListener
              // added to the buttons retrieves the user's selection and calls
              // dialog.setVisible(false) if OK is clicked, or calls dialog.dispose()
              // if Cancel is clicked.
         }Now, everything works fine if the JDialog is modal, but if I make it non-modal only the window decorations of the JDialog are painted, and the control doesn't return to the main GUI. Calling doLayout() or repaint() on the doSelection() has no effect. How can this be fixed?
    I hope I have been able to explain the problem satisfactorily, I could not create a suitable SSCCEE to show you. Thanks in advance for any hint.

    Ok, I've taken some time to think about this problem and I've modified the code a bit.
    Now the dialog shows itself and is responsive (i.e. its JLists can be operated), but the Ok button does not close the dialog as I'd want. I believe that I'm messing up things about threading, and the operations in actionPerformed() should be carried out in another thread, if possible.
    Thanks in advance for any hint / suggestion / comment / insult.
         private Data[] selection;
         /** Constructor */
         public MyDialog() {
              // ... Here is the code that builds the dialog...
              dialog.setModal(false);
              dialog.pack();
              // Note that the dialog is not visible yet
         public Data[] doSelection() {
              operatorAnswer = NONE_YET;
              dialog.setVisible(true);          
              while (operatorAnswer == NONE_YET) {
                   try {
                        wait();
                   } catch (InterruptedException e) { }
              return (operatorAnswer == OK ? selection : null);
         public void actionPerformed(ActionEvent evt) {
              if (okButton.equals(evt.getSource())) {
                   operatorAnswer = OK;
                   retrieveSelection();
                   dialog.setVisible(false);
              else if (cancelButton.equals(evt.getSource())) {               
                   operatorAnswer = CANCEL;
                   dialog.dispose();
         private void retrieveSelection() {
              // ... Here is the code that retrieves selected data from the dialog's JLists
              // and stores it in the "selection" private array...
              notifyAll();
         }

  • Inconsistent results from AlphaComposite and AffineTransform

    I'm developing a game using Java, and I've run into a fairly major issue. On my primary development machine, I can use combinations of AlphaComposite.SRC_IN and AffineTransforms with rotation just fine (I'm using the composite to create a lighting overlay for the game by drawing light beams onto the alpha channel of an all-black image buffer). On my other computer, while the image itself rotates and draws on the alpha channel fine, the computer also completely clears a bounding rectangle around the rotated image.
    The first computer (the one for which this works) has a GeForce 8800GTS video card, while the second has an older Radeon 9700. The first computer also has the most recent version of the JDK (6). Could either of these factors make the difference?
    edit: Upgrading to JDK 6 fixed it. Will need to include a notice about upgrading to JDK 6 with the game, probably.
    Message was edited by:
    Hyouko

    Hi
    Yes I have a debug line that prints them out in the doAutoLoadBalancing method - this is the point where I am diagnosing the problem. It only prints the correct results after I have already run the procedure from the SQL command line.
    public UserNumber[] doAutoLoadBalancing () throws SQLException {
    autoLBNumbersNeeded.clearParameters();
    autoLBNumbersNeeded.execute();
    mwFF = autoLBNumbersNeeded.getLong(1);
    mwHF = autoLBNumbersNeeded.getLong(2);
    wmFF = autoLBNumbersNeeded.getLong(3);
    wmHF = autoLBNumbersNeeded.getLong(4);
    autoLBNumbersNeeded.clearParameters();
    if (m_cat.isDebugEnabled()) {m_cat.debug("mwFF: "+mwFF+"; mwHF: " +mwHF+"; wmFF: "+wmFF+"; wmHF: "+wmHF);}
    </pre>

  • Report painter  and drill down reports

    Hi SAP gurus,
                   Can any froward configuration of  report painter  and drill down reports.
       iassign points

    Hiii Sai Krishna,
    can u forward the same documentation to me..plsss
    my mail id - [email protected]
    thanks in advance
    regards
    ramki

Maybe you are looking for

  • How do i remove my wife's iphone contacts from my iphone?

    As a family we have three iphones and two ipads. So I recently bought an imac to make things easier instead of our old pc. but in the process of setting it up, i imported all my contacts from my iphone and ipad onto the icloud and as a result, they a

  • How to Default Appraisal Template in MSS Performance Management

    Dear Friends How can we default a certain Appraisal Template in MSS Performance Management Status Overview. We currently have Appriasal Templatate I ( Used in 2008) Appriasal Templatate II ( Used in 2009) Appriasal Templatate III ( Used in 2010) In t

  • Crazy Headphone problem? Speaker no longer works in some cases

    Gang, Basically my phone work just fine. But when I get a call I have to put it on speaker phone to listen to anything. Also when I adjust the volume it always indicates Headphone. and Yes I do not have my headphones in. I looked at the cleaning thin

  • Graph shared x values

    I have data where there is four columns of data.  On the numbers on Mac you can share the X-value in column 1 with the y values in the other 3 columns.  Is there a way to do this on the iPad numbers app?   Looking to generate scatter plots to check f

  • Send a mail

    Hi, I'm looking for a Forté command to send automatically a mail with a body message and a file attached . I have tried these lines: Cmd.setvalue('start mailto:adresshere.com?subject=Trial'); task.part.operatingsystem.runCommand(command=Cmd); But the