User: juha    
  Date: 01/02/18 12:31:02

  Modified:    src/org/jboss/admin/monitor/graph DefaultGraphModel.java
                        DefaultGraphRenderer.java GraphRenderer.java
                        InvocationTimeGraphModel.java
  Added:       src/org/jboss/admin/monitor/graph GraphController.java
  Log:
  Initial markers for the graph.
  
  Revision  Changes    Path
  1.2       +1 -1      admin/src/org/jboss/admin/monitor/graph/DefaultGraphModel.java
  
  Index: DefaultGraphModel.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/admin/src/org/jboss/admin/monitor/graph/DefaultGraphModel.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultGraphModel.java    2000/12/17 20:11:23     1.1
  +++ DefaultGraphModel.java    2001/02/18 20:31:01     1.2
  @@ -23,7 +23,7 @@
   public class DefaultGraphModel implements GraphModel {
   
       
  -    protected List xAxis = Collections.synchronizedList(new ArrayList());
  +    protected Collection xAxis = Collections.synchronizedList(new ArrayList());
       
       protected EventListenerList listenerList = new EventListenerList();
       
  
  
  
  1.3       +23 -11    
admin/src/org/jboss/admin/monitor/graph/DefaultGraphRenderer.java
  
  Index: DefaultGraphRenderer.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/admin/src/org/jboss/admin/monitor/graph/DefaultGraphRenderer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultGraphRenderer.java 2000/12/29 22:36:25     1.2
  +++ DefaultGraphRenderer.java 2001/02/18 20:31:01     1.3
  @@ -7,15 +7,16 @@
   import java.awt.Insets;
   import java.awt.Point;
   import java.awt.Rectangle;
  -
   import java.util.ArrayList;
   import java.util.Collections;
   import java.util.Comparator;
   import java.util.Iterator;
   import java.util.NoSuchElementException;
   import java.io.Serializable;
  -
   import javax.swing.JPanel;
  +import javax.swing.border.BevelBorder;
  +import javax.swing.plaf.metal.MetalTheme;
  +import javax.swing.plaf.metal.DefaultMetalTheme;
   
   // non-standard class dependencies
   import org.jboss.admin.monitor.GraphView;
  @@ -52,7 +53,9 @@
       private double max          = 1.0d;
   
       private ArrayList points    = new ArrayList();
  +
              
  +    GraphController controller = new GraphController(GraphController.VERTICAL);
                   
   /*
    *************************************************************************
  @@ -67,8 +70,8 @@
           // show default background color
           setOpaque(true);
           
  -        // set default background color
  -        setBackground(Color.black);
  +        // set bevel border around the graph (not the controls though)
  +        setBorder(new BevelBorder(BevelBorder.LOWERED));     
       }   
       
   
  @@ -102,6 +105,20 @@
           
           return this;
       }
  +    
  +    public Component getHorizontalControlRendererObject(GraphView graph) {
  +     
  +        return new GraphController(GraphController.HORIZONTAL);
  +    }
  +    
  +    public Component getVerticalControlRendererObject(GraphView graph) {
  +        
  +        controller.setVerticalGridGap(gridGapWidth);
  +        controller.setVerticalMinValue(0);
  +        controller.setVerticalMaxValue(max);
  +        
  +        return controller;
  +    }
   
       public void valueAppended(GraphModelEvent evt) {   
   
  @@ -122,12 +139,6 @@
    *************************************************************************
    */
    
  -    public void addNotify() {
  -        super.addNotify();
  -        
  -        //Insets insets = getInsets();
  -        //this.max = getHeight() - insets.top - insets.bottom;
  -    }
       
       public void paintComponent(Graphics g) {
           
  @@ -191,7 +202,8 @@
        */
       private void drawBackground(Graphics g) {
           
  -        g.setColor(getBackground());
  +        MetalTheme theme = new DefaultMetalTheme();
  +        g.setColor(Color.black);
           
           Rectangle rect = g.getClipBounds();
           g.fillRect(rect.x, rect.y, rect.width, rect.height);
  
  
  
  1.2       +2 -0      admin/src/org/jboss/admin/monitor/graph/GraphRenderer.java
  
  Index: GraphRenderer.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/admin/src/org/jboss/admin/monitor/graph/GraphRenderer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- GraphRenderer.java        2000/12/17 20:11:23     1.1
  +++ GraphRenderer.java        2001/02/18 20:31:01     1.2
  @@ -16,6 +16,8 @@
   public interface GraphRenderer extends GraphModelListener {
   
       Component getGraphRendererObject(GraphView graph);
  +    Component getVerticalControlRendererObject(GraphView graph);
  +    Component getHorizontalControlRendererObject(GraphView graph);
       
   }
   
  
  
  
  1.2       +5 -1      
admin/src/org/jboss/admin/monitor/graph/InvocationTimeGraphModel.java
  
  Index: InvocationTimeGraphModel.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/admin/src/org/jboss/admin/monitor/graph/InvocationTimeGraphModel.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- InvocationTimeGraphModel.java     2000/12/17 20:11:23     1.1
  +++ InvocationTimeGraphModel.java     2001/02/18 20:31:01     1.2
  @@ -4,11 +4,13 @@
   import java.util.Map;
   import java.util.List;
   import java.util.Collections;
  +import java.util.Collection;
   import java.util.HashMap;
   import java.util.ArrayList;
   
   // non-standard class dependencies
  -import org.jboss.admin.InvocationEntry;
  +import org.jboss.admin.dataholder.InvocationEntry;
  +import org.gjt.lindfors.util.BoundBuffer;
   
   
   /**
  @@ -30,6 +32,8 @@
   
       private Map  txMap      = Collections.synchronizedMap(new HashMap());
       private List resultList = Collections.synchronizedList(new ArrayList());
  +    
  +    protected Collection xAxis = new BoundBuffer(1000);
       
       private int mode = CONTINUOUS_UPDATE;
       
  
  
  
  1.1                  admin/src/org/jboss/admin/monitor/graph/GraphController.java
  
  Index: GraphController.java
  ===================================================================
  /*
   * Class GraphController
   * Copyright (C) 2001  Juha Lindfors
   *
   * This library is free software; you can redistribute it and/or
   * modify it under the terms of the GNU Library General Public
   * License as published by the Free Software Foundation; either
   * version 2 of the License, or (at your option) any later version.
   *
   * This library is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   * Library General Public License for more details.
   *
   * You should have received a copy of the GNU Library General Public
   * License along with this library; if not, write to the
   * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
   * Boston, MA  02111-1307, USA.
   *
   * This package and its source code is available at www.jboss.org
   * $Id: GraphController.java,v 1.1 2001/02/18 20:31:01 juha Exp $
   */     
  package org.jboss.admin.monitor.graph;
  
  // standard imports
  import java.awt.Graphics;
  import java.awt.Rectangle;
  import java.awt.Insets;
  import java.awt.Color;
  import java.awt.Dimension;
  import java.text.DecimalFormat;
  import java.text.FieldPosition;
  import java.text.NumberFormat;
  
  import javax.swing.JPanel;
  import javax.swing.plaf.metal.MetalTheme;
  import javax.swing.plaf.metal.DefaultMetalTheme;
   
  /**
   * ...
   *
   * @author  <a href="mailto:[EMAIL PROTECTED]">Juha Lindfors</a>
   * @version $Revision: 1.1 $
   */     
  public class GraphController extends JPanel {
  
      /** Component orientation. */
      public final static int HORIZONTAL = 1;
      /** Component orientation. */
      public final static int VERTICAL   = 2;
      
      private int orientation = HORIZONTAL;
      
      private double vertMin  = 0.0;
      private double vertMax  = 100.0;
      private int vertGridGap = 10;
      private int horzGridGap = 10;
      
      
  /*
   *************************************************************************
   *
   *      CONSTRUCTORS
   *
   *************************************************************************
   */     
   
      /*
       * default constructor. default orientation = horiz.
       */
      public GraphController() {    }
      
      public GraphController(int orientation) {
          this();
          
          if (orientation == VERTICAL)
              this.orientation = VERTICAL;
          else 
              this.orientation = HORIZONTAL;
      }
      
  /*
   *************************************************************************
   *
   *      PUBLIC INSTANCE METHODS
   *
   *************************************************************************
   */     
   
      public void setVerticalMinValue(double d) {
          this.vertMin = d; 
      }
      
      public void setVerticalMaxValue(double d) {
          this.vertMax = d;
      }
      
      public void setVerticalGridGap(int gap) {
          this.vertGridGap = gap;    
      }
      
      public void setHorizontalGridGap(int gap) {
          
      }
   
  /*
   *************************************************************************
   *
   *      METHOD OVERRIDES
   *
   *************************************************************************
   */     
  
      public Dimension getMinimumSize() {
          return new Dimension(40, 20);
      }
      
      public Dimension getPreferredSize() {
          return new Dimension(40, 20);
      }
      
      public void paintComponent(Graphics g) {
          
          // draw background first
          super.paintComponent(g);
          
          // get width, height and insets
          int width     = getWidth();
          int height    = getHeight();
          Insets insets = getInsets();
          
          // use work variables to take insets into account
          int w = width  - insets.left - insets.right;
          int h = height - insets.top  - insets.bottom;
          int x = insets.left;
          int y = insets.top;
          
          // check which area needs to be painted
          Rectangle clip = g.getClipBounds();
          
          // store the old clip state
          boolean wasNullClipArea = false;
          
          // no args repaint was called
          if (clip == null) {
              
              // leave insets out of the clip area
              g.setClip(x, y, width, height);
              
              wasNullClipArea = true;
          }
          
          // draw the grid line markers
          drawLineMarkers(g);
  
          // restore the old clip area    
          if (wasNullClipArea)
              g.setClip(null);
      }
      
      
  /*
   *************************************************************************
   *
   *      PRIVATE INSTANCE METHODS
   *
   *************************************************************************
   */     
   
      private void drawLineMarkers(Graphics g) {
      
          if (orientation == VERTICAL)
              drawVerticalMarkers(g);
          else 
              drawHorizontalMarkers(g);            
      }
      
      private void drawVerticalMarkers(Graphics g) {
  
          Rectangle r = g.getClipBounds();
          MetalTheme theme = new DefaultMetalTheme();
          
          g.setColor(theme.getFocusColor());
          g.setFont(theme.getControlTextFont());
          
          int markerCount = 0;
          
          for (int y = r.height - 1; y >= 0; y -= vertGridGap, markerCount++) 
              g.drawLine(r.width - 5, y, r.width - 3, y);
              
          g.drawLine(r.width - 2, 0, r.width - 2, r.height);    
          
          double d        = 50.0 / vertGridGap;
          int labelSkip   = 1;
          
          if (d >= 1)
              labelSkip = (int)d;
              
          // [TODO] localize the format
          DecimalFormat format = new DecimalFormat("#.#");
          
          for (int i = 0; i < markerCount; ++i) {
              if (i % labelSkip == 0) {
                  StringBuffer value = format.format((i*vertGridGap*vertMax)/r.height, 
new StringBuffer(), new FieldPosition(NumberFormat.FRACTION_FIELD));
                  
g.drawString(value.toString()/*String.valueOf((i*vertGridGap*vertMax)/r.height)*/,
                               0, r.height - 1 - i*vertGridGap + 5);
              }
          }
          
      }
      
      private void drawHorizontalMarkers(Graphics g) {
      
              
      }
  }
   
   
  
  
  

Reply via email to