added option to use fixed custom color for text/dial in dashboard gauge widgets
authorVictor Kirhenshtein <victor@netxms.org>
Fri, 22 Apr 2016 15:18:03 +0000 (18:18 +0300)
committerVictor Kirhenshtein <victor@netxms.org>
Fri, 22 Apr 2016 15:18:03 +0000 (18:18 +0300)
26 files changed:
ChangeLog
src/java/netxms-eclipse/Charts/src/org/netxms/ui/eclipse/charts/api/DataPoint.java
src/java/netxms-eclipse/Charts/src/org/netxms/ui/eclipse/charts/api/Gauge.java
src/java/netxms-eclipse/Charts/src/org/netxms/ui/eclipse/charts/api/GaugeColorMode.java [new file with mode: 0644]
src/java/netxms-eclipse/Charts/src/org/netxms/ui/eclipse/charts/widgets/CurrentValueWidget.java
src/java/netxms-eclipse/Charts/src/org/netxms/ui/eclipse/charts/widgets/DialChartWidget.java
src/java/netxms-eclipse/Charts/src/org/netxms/ui/eclipse/charts/widgets/GaugeWidget.java
src/java/netxms-eclipse/Dashboard/src/org/netxms/ui/eclipse/dashboard/propertypages/Gauge.java
src/java/netxms-eclipse/Dashboard/src/org/netxms/ui/eclipse/dashboard/widgets/GaugeElement.java
src/java/netxms-eclipse/Dashboard/src/org/netxms/ui/eclipse/dashboard/widgets/internal/GaugeConfig.java
webui/webapp/Charts/src/org/netxms/ui/eclipse/charts/api/DataPoint.java
webui/webapp/Charts/src/org/netxms/ui/eclipse/charts/api/Gauge.java
webui/webapp/Charts/src/org/netxms/ui/eclipse/charts/api/GaugeColorMode.java [new file with mode: 0644]
webui/webapp/Charts/src/org/netxms/ui/eclipse/charts/messages.properties
webui/webapp/Charts/src/org/netxms/ui/eclipse/charts/messages_cs.properties
webui/webapp/Charts/src/org/netxms/ui/eclipse/charts/messages_de.properties
webui/webapp/Charts/src/org/netxms/ui/eclipse/charts/messages_es.properties
webui/webapp/Charts/src/org/netxms/ui/eclipse/charts/messages_fr.properties
webui/webapp/Charts/src/org/netxms/ui/eclipse/charts/messages_ru.properties
webui/webapp/Charts/src/org/netxms/ui/eclipse/charts/messages_zh_CN.properties
webui/webapp/Charts/src/org/netxms/ui/eclipse/charts/widgets/CurrentValueWidget.java
webui/webapp/Charts/src/org/netxms/ui/eclipse/charts/widgets/DialChartWidget.java
webui/webapp/Charts/src/org/netxms/ui/eclipse/charts/widgets/GaugeWidget.java
webui/webapp/Dashboard/src/org/netxms/ui/eclipse/dashboard/propertypages/Gauge.java
webui/webapp/Dashboard/src/org/netxms/ui/eclipse/dashboard/widgets/GaugeElement.java
webui/webapp/Dashboard/src/org/netxms/ui/eclipse/dashboard/widgets/internal/GaugeConfig.java

index 5633fef..51f3efa 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,9 @@
 *
 
 - New parameters in Linux platform subagent to get additional CPU information (frequency, model, etc.)
+- Management console
+       - Improved dashboard gauge widget
+       - Added translucence option for dashboard line charts
 - Android console
        - Reorganized alarm notification section (issue #1194)
 - Fixed issues: #1194, #1200
index 758b054..c887692 100644 (file)
@@ -1,5 +1,20 @@
 /**
- * 
+ * NetXMS - open source network management system
+ * Copyright (C) 2003-2016 Victor Kirhenshtein
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 package org.netxms.ui.eclipse.charts.api;
 
index a970671..1a003ad 100644 (file)
@@ -18,6 +18,8 @@
  */
 package org.netxms.ui.eclipse.charts.api;
 
+import org.eclipse.swt.graphics.RGB;
+
 /**
  * Gauge interface
  */
@@ -126,4 +128,32 @@ public interface Gauge extends DataComparisonChart
         * @param fontName
         */
        public void setFontName(String fontName);
+       
+       /**
+        * Get color mode
+        * 
+        * @return
+        */
+       public GaugeColorMode getColorMode();
+       
+       /**
+        * Set color mode
+        * 
+        * @param mode
+        */
+       public void setColorMode(GaugeColorMode mode);
+       
+       /**
+        * Get custom color
+        * 
+        * @return
+        */
+       public RGB getCustomColor();
+       
+       /**
+        * Set custom color
+        * 
+        * @param color
+        */
+       public void setCustomColor(RGB color);
 }
diff --git a/src/java/netxms-eclipse/Charts/src/org/netxms/ui/eclipse/charts/api/GaugeColorMode.java b/src/java/netxms-eclipse/Charts/src/org/netxms/ui/eclipse/charts/api/GaugeColorMode.java
new file mode 100644 (file)
index 0000000..f1bb06f
--- /dev/null
@@ -0,0 +1,75 @@
+/**
+ * NetXMS - open source network management system
+ * Copyright (C) 2003-2016 Victor Kirhenshtein
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.netxms.ui.eclipse.charts.api;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.netxms.base.Logger;
+
+/**
+ * Gauge color mode
+ */
+public enum GaugeColorMode
+{
+   ZONE(0),
+   CUSTOM(1),
+   THRESHOLD(2);
+   
+   private int value;
+   private static Map<Integer, GaugeColorMode> lookupTable = new HashMap<Integer, GaugeColorMode>();
+
+   static
+   {
+      for(GaugeColorMode element : GaugeColorMode.values())
+      {
+         lookupTable.put(element.value, element);
+      }
+   }
+
+   /**
+    * @param value
+    */
+   private GaugeColorMode(int value)
+   {
+      this.value = value;
+   }
+
+   /**
+    * @return
+    */
+   public int getValue()
+   {
+      return value;
+   }
+
+   /**
+    * @param value
+    * @return
+    */
+   public static GaugeColorMode getByValue(int value)
+   {
+      final GaugeColorMode element = lookupTable.get(value);
+      if (element == null)
+      {
+         Logger.warning(GaugeColorMode.class.getName(), "Unknown element " + value);
+         return ZONE; // fallback
+      }
+      return element;
+   }
+}
index 7ad8c9c..a54e3ce 100644 (file)
@@ -94,17 +94,28 @@ public class CurrentValueWidget extends GaugeWidget
                final String value = getValueAsDisplayString(dci);
                final Font font = WidgetHelper.getBestFittingFont(gc, valueFonts, value, rect.width, rect.height); //$NON-NLS-1$
                gc.setFont(font);
-               if ((dci.getValue() <= leftRedZone) || (dci.getValue() >= rightRedZone))
+               switch(colorMode)
                {
-                       gc.setForeground(colors.create(RED_ZONE_COLOR));
-               }
-               else if ((dci.getValue() <= leftYellowZone) || (dci.getValue() >= rightYellowZone))
-               {
-                       gc.setForeground(colors.create(YELLOW_ZONE_COLOR));
-               }
-               else
-               {
-                       gc.setForeground(colors.create(GREEN_ZONE_COLOR));
+                  case ZONE:
+               if ((dci.getValue() <= leftRedZone) || (dci.getValue() >= rightRedZone))
+               {
+                       gc.setForeground(colors.create(RED_ZONE_COLOR));
+               }
+               else if ((dci.getValue() <= leftYellowZone) || (dci.getValue() >= rightYellowZone))
+               {
+                       gc.setForeground(colors.create(YELLOW_ZONE_COLOR));
+               }
+               else
+               {
+                       gc.setForeground(colors.create(GREEN_ZONE_COLOR));
+               }
+               break;
+                  case CUSTOM:
+                  gc.setForeground(colors.create(customColor));
+                  break;
+         default:
+            gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_BLACK));
+            break;
                }
                Point ext = gc.textExtent(value, SWT.DRAW_TRANSPARENT);
                gc.drawText(value, rect.x + rect.width / 2 - ext.x / 2, rect.y + rect.height / 2 - ext.y / 2, SWT.TRANSPARENT);
index 76fe42b..177a11f 100644 (file)
@@ -122,12 +122,22 @@ public class DialChartWidget extends GaugeWidget
                gc.fillArc(rect.x, rect.y, rect.width, rect.height, 0, 360);
                
                // Draw zones
-               int startAngle = 225;
-               startAngle = drawZone(gc, rect, startAngle, minValue, leftRedZone, angleValue, RED_ZONE_COLOR);
-               startAngle = drawZone(gc, rect, startAngle, leftRedZone, leftYellowZone, angleValue, YELLOW_ZONE_COLOR);
-               startAngle = drawZone(gc, rect, startAngle, leftYellowZone, rightYellowZone, angleValue, GREEN_ZONE_COLOR);
-               startAngle = drawZone(gc, rect, startAngle, rightYellowZone, rightRedZone, angleValue, YELLOW_ZONE_COLOR);
-               startAngle = drawZone(gc, rect, startAngle, rightRedZone, maxValue, angleValue, RED_ZONE_COLOR);
+               switch(colorMode)
+               {
+                  case ZONE:
+                     int startAngle = 225;
+                     startAngle = drawZone(gc, rect, startAngle, minValue, leftRedZone, angleValue, RED_ZONE_COLOR);
+                     startAngle = drawZone(gc, rect, startAngle, leftRedZone, leftYellowZone, angleValue, YELLOW_ZONE_COLOR);
+                     startAngle = drawZone(gc, rect, startAngle, leftYellowZone, rightYellowZone, angleValue, GREEN_ZONE_COLOR);
+                     startAngle = drawZone(gc, rect, startAngle, rightYellowZone, rightRedZone, angleValue, YELLOW_ZONE_COLOR);
+                     startAngle = drawZone(gc, rect, startAngle, rightRedZone, maxValue, angleValue, RED_ZONE_COLOR);
+                     break;
+                  case CUSTOM:
+            drawZone(gc, rect, 225, minValue, maxValue, angleValue, customColor);
+                     break;
+                  default:
+                     break;
+               }
                
                // Draw center part and border
                gc.setBackground(getColorFromPreferences("Chart.Colors.PlotArea")); //$NON-NLS-1$
@@ -326,4 +336,15 @@ public class DialChartWidget extends GaugeWidget
                gc.dispose();
                return image;
        }
+
+   /**
+    * Get minimal element size
+    * 
+    * @return
+    */
+       @Override
+   protected Point getMinElementSize()
+   {
+      return new Point(40, 40);
+   }
 }
index 1f13a82..5ac92e3 100644 (file)
@@ -41,6 +41,7 @@ import org.netxms.client.datacollection.Threshold;
 import org.netxms.ui.eclipse.charts.Activator;
 import org.netxms.ui.eclipse.charts.api.ChartColor;
 import org.netxms.ui.eclipse.charts.api.Gauge;
+import org.netxms.ui.eclipse.charts.api.GaugeColorMode;
 import org.netxms.ui.eclipse.charts.widgets.internal.DataComparisonElement;
 import org.netxms.ui.eclipse.tools.ColorCache;
 
@@ -72,6 +73,8 @@ public abstract class GaugeWidget extends GenericChart implements Gauge, PaintLi
    protected boolean gridVisible = true;
    protected boolean elementBordersVisible = false;
    protected String fontName = "Verdana"; //$NON-NLS-1$
+   protected GaugeColorMode colorMode = GaugeColorMode.ZONE;
+   protected RGB customColor = new RGB(0, 0, 0);
 
    private boolean fontsCreated = false;
 
@@ -411,7 +414,8 @@ public abstract class GaugeWidget extends GenericChart implements Gauge, PaintLi
       {
          int w = (size.x - OUTER_MARGIN_WIDTH * 2);
          int h = (size.y - OUTER_MARGIN_HEIGHT - top) / parameters.size();
-         if ((w > 40) && (h > 40 * parameters.size()))
+         Point minSize = getMinElementSize();
+         if ((w >= minSize.x) && (h >= minSize.x))
          {
             for(int i = 0; i < parameters.size(); i++)
             {
@@ -423,7 +427,8 @@ public abstract class GaugeWidget extends GenericChart implements Gauge, PaintLi
       {
          int w = (size.x - OUTER_MARGIN_WIDTH * 2) / parameters.size();
          int h = size.y - OUTER_MARGIN_HEIGHT - top;
-         if ((w > 40 * parameters.size()) && (h > 40))
+         Point minSize = getMinElementSize();
+         if ((w >= minSize.x) && (h >= minSize.x))
          {
             for(int i = 0; i < parameters.size(); i++)
             {
@@ -434,6 +439,16 @@ public abstract class GaugeWidget extends GenericChart implements Gauge, PaintLi
 
       gc.dispose();
    }
+   
+   /**
+    * Get minimal element size
+    * 
+    * @return
+    */
+   protected Point getMinElementSize()
+   {
+      return new Point(10, 10);
+   }
 
    /**
     * @param dataComparisonElement
@@ -726,8 +741,47 @@ public abstract class GaugeWidget extends GenericChart implements Gauge, PaintLi
       }
    }
 
+   /* (non-Javadoc)
+    * @see org.netxms.ui.eclipse.charts.api.DataChart#setYAxisRange(int, int)
+    */
    @Override
    public void setYAxisRange(int from, int to)
    {
    }
+
+   /* (non-Javadoc)
+    * @see org.netxms.ui.eclipse.charts.api.Gauge#getColorMode()
+    */
+   @Override
+   public GaugeColorMode getColorMode()
+   {
+      return colorMode;
+   }
+
+   /* (non-Javadoc)
+    * @see org.netxms.ui.eclipse.charts.api.Gauge#setGaugeColorMode(org.netxms.ui.eclipse.charts.api.GaugeColorMode)
+    */
+   @Override
+   public void setColorMode(GaugeColorMode mode)
+   {
+      colorMode = mode;
+   }
+
+   /* (non-Javadoc)
+    * @see org.netxms.ui.eclipse.charts.api.Gauge#getCustomColor()
+    */
+   @Override
+   public RGB getCustomColor()
+   {
+      return customColor;
+   }
+
+   /* (non-Javadoc)
+    * @see org.netxms.ui.eclipse.charts.api.Gauge#setCustomColor(org.eclipse.swt.graphics.RGB)
+    */
+   @Override
+   public void setCustomColor(RGB color)
+   {
+      customColor = color;
+   }
 }
index d0915af..477d3d7 100644 (file)
  */
 package org.netxms.ui.eclipse.dashboard.propertypages;
 
+import org.eclipse.jface.preference.ColorSelector;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Button;
@@ -26,8 +29,10 @@ import org.eclipse.swt.widgets.Combo;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.ui.dialogs.PropertyPage;
+import org.netxms.ui.eclipse.charts.api.GaugeColorMode;
 import org.netxms.ui.eclipse.dashboard.Messages;
 import org.netxms.ui.eclipse.dashboard.widgets.internal.GaugeConfig;
+import org.netxms.ui.eclipse.tools.ColorConverter;
 import org.netxms.ui.eclipse.tools.MessageDialogHelper;
 import org.netxms.ui.eclipse.tools.WidgetHelper;
 import org.netxms.ui.eclipse.widgets.LabeledText;
@@ -49,6 +54,8 @@ public class Gauge extends PropertyPage
        private LabeledText leftRedZone;
        private LabeledText rightYellowZone;
        private LabeledText rightRedZone;
+       private Combo colorMode;
+       private ColorSelector customColor;
 
        /* (non-Javadoc)
         * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
@@ -131,6 +138,33 @@ public class Gauge extends PropertyPage
                gd.horizontalAlignment = SWT.FILL;
                gd.grabExcessHorizontalSpace = true;
                rightRedZone.setLayoutData(gd);
+
+      gd = new GridData();
+      gd.horizontalAlignment = SWT.FILL;
+      gd.grabExcessHorizontalSpace = true;
+      colorMode = WidgetHelper.createLabeledCombo(dialogArea, SWT.READ_ONLY, "Color mode", gd);
+      colorMode.add("Zone color");
+      colorMode.add("Fixed custom color");
+      colorMode.add("Active threshold color");
+      colorMode.select(config.getColorMode());
+      colorMode.addSelectionListener(new SelectionListener() {
+         @Override
+         public void widgetSelected(SelectionEvent e)
+         {
+            onColorModeChange(colorMode.getSelectionIndex());
+         }
+         
+         @Override
+         public void widgetDefaultSelected(SelectionEvent e)
+         {
+            widgetSelected(e);
+         }
+      });
+      
+      gd = new GridData();
+      gd.horizontalAlignment = SWT.LEFT;
+      customColor = WidgetHelper.createLabeledColorSelector(dialogArea, "Custom color", gd); 
+      customColor.setColorValue(ColorConverter.rgbFromInt(config.getCustomColor()));
                
                checkLegendInside = new Button(dialogArea, SWT.CHECK);
                checkLegendInside.setText(Messages.get().DialChart_LegendInside);
@@ -159,6 +193,7 @@ public class Gauge extends PropertyPage
       gd.horizontalSpan = 2;
       checkElementBorders.setLayoutData(gd);
       
+      onColorModeChange(config.getColorMode());
                return dialogArea;
        }
 
@@ -195,6 +230,22 @@ public class Gauge extends PropertyPage
                config.setLegendInside(checkLegendInside.getSelection());
                config.setVertical(checkVertical.getSelection());
                config.setElementBordersVisible(checkElementBorders.getSelection());
+               config.setColorMode(colorMode.getSelectionIndex());
+               config.setCustomColor(ColorConverter.rgbToInt(customColor.getColorValue()));
                return true;
        }
+       
+       /**
+        * Handle color mode change
+        * 
+        * @param newMode
+        */
+       private void onColorModeChange(int newMode)
+       {
+          leftYellowZone.setEnabled(newMode == GaugeColorMode.ZONE.getValue());
+          leftRedZone.setEnabled(newMode == GaugeColorMode.ZONE.getValue());
+      rightYellowZone.setEnabled(newMode == GaugeColorMode.ZONE.getValue());
+      rightRedZone.setEnabled(newMode == GaugeColorMode.ZONE.getValue());
+          customColor.setEnabled(newMode == GaugeColorMode.CUSTOM.getValue());
+       }
 }
index c302118..00fb198 100644 (file)
@@ -26,7 +26,9 @@ import org.netxms.ui.eclipse.charts.api.ChartColor;
 import org.netxms.ui.eclipse.charts.api.ChartDciConfig;
 import org.netxms.ui.eclipse.charts.api.ChartFactory;
 import org.netxms.ui.eclipse.charts.api.Gauge;
+import org.netxms.ui.eclipse.charts.api.GaugeColorMode;
 import org.netxms.ui.eclipse.dashboard.widgets.internal.GaugeConfig;
+import org.netxms.ui.eclipse.tools.ColorConverter;
 
 /**
  * Dial chart element
@@ -77,6 +79,8 @@ public class GaugeElement extends ComparisonChartElement
                ((Gauge)chart).setRightYellowZone(config.getRightYellowZone());
                ((Gauge)chart).setRightRedZone(config.getRightRedZone());
                ((Gauge)chart).setFontName(config.getFontName());
+               ((Gauge)chart).setColorMode(GaugeColorMode.getByValue(config.getColorMode()));
+               ((Gauge)chart).setCustomColor(ColorConverter.rgbFromInt(config.getCustomColor()));
                
                int index = 0;
                for(ChartDciConfig dci : config.getDciList())
index 4b4e8cb..aeed91e 100644 (file)
@@ -3,6 +3,7 @@
  */
 package org.netxms.ui.eclipse.dashboard.widgets.internal;
 
+import org.netxms.ui.eclipse.charts.api.GaugeColorMode;
 import org.simpleframework.xml.Element;
 import org.simpleframework.xml.Serializer;
 import org.simpleframework.xml.core.Persister;
@@ -50,6 +51,12 @@ public class GaugeConfig extends AbstractChartConfig
        @Element(required=false)
        private boolean elementBordersVisible = false;
        
+   @Element(required=false)
+   private int colorMode = GaugeColorMode.ZONE.getValue();
+   
+   @Element(required=false)
+   private int customColor = 0;
+   
        /**
         * Create dial chart settings object from XML document
         * 
@@ -238,4 +245,36 @@ public class GaugeConfig extends AbstractChartConfig
    {
       this.elementBordersVisible = elementBordersVisible;
    }
+
+   /**
+    * @return the colorMode
+    */
+   public int getColorMode()
+   {
+      return colorMode;
+   }
+
+   /**
+    * @param colorMode the colorMode to set
+    */
+   public void setColorMode(int colorMode)
+   {
+      this.colorMode = colorMode;
+   }
+
+   /**
+    * @return the customColor
+    */
+   public int getCustomColor()
+   {
+      return customColor;
+   }
+
+   /**
+    * @param customColor the customColor to set
+    */
+   public void setCustomColor(int customColor)
+   {
+      this.customColor = customColor;
+   }
 }
index 758b054..c887692 100644 (file)
@@ -1,5 +1,20 @@
 /**
- * 
+ * NetXMS - open source network management system
+ * Copyright (C) 2003-2016 Victor Kirhenshtein
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 package org.netxms.ui.eclipse.charts.api;
 
index a970671..1a003ad 100644 (file)
@@ -18,6 +18,8 @@
  */
 package org.netxms.ui.eclipse.charts.api;
 
+import org.eclipse.swt.graphics.RGB;
+
 /**
  * Gauge interface
  */
@@ -126,4 +128,32 @@ public interface Gauge extends DataComparisonChart
         * @param fontName
         */
        public void setFontName(String fontName);
+       
+       /**
+        * Get color mode
+        * 
+        * @return
+        */
+       public GaugeColorMode getColorMode();
+       
+       /**
+        * Set color mode
+        * 
+        * @param mode
+        */
+       public void setColorMode(GaugeColorMode mode);
+       
+       /**
+        * Get custom color
+        * 
+        * @return
+        */
+       public RGB getCustomColor();
+       
+       /**
+        * Set custom color
+        * 
+        * @param color
+        */
+       public void setCustomColor(RGB color);
 }
diff --git a/webui/webapp/Charts/src/org/netxms/ui/eclipse/charts/api/GaugeColorMode.java b/webui/webapp/Charts/src/org/netxms/ui/eclipse/charts/api/GaugeColorMode.java
new file mode 100644 (file)
index 0000000..f1bb06f
--- /dev/null
@@ -0,0 +1,75 @@
+/**
+ * NetXMS - open source network management system
+ * Copyright (C) 2003-2016 Victor Kirhenshtein
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.netxms.ui.eclipse.charts.api;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.netxms.base.Logger;
+
+/**
+ * Gauge color mode
+ */
+public enum GaugeColorMode
+{
+   ZONE(0),
+   CUSTOM(1),
+   THRESHOLD(2);
+   
+   private int value;
+   private static Map<Integer, GaugeColorMode> lookupTable = new HashMap<Integer, GaugeColorMode>();
+
+   static
+   {
+      for(GaugeColorMode element : GaugeColorMode.values())
+      {
+         lookupTable.put(element.value, element);
+      }
+   }
+
+   /**
+    * @param value
+    */
+   private GaugeColorMode(int value)
+   {
+      this.value = value;
+   }
+
+   /**
+    * @return
+    */
+   public int getValue()
+   {
+      return value;
+   }
+
+   /**
+    * @param value
+    * @return
+    */
+   public static GaugeColorMode getByValue(int value)
+   {
+      final GaugeColorMode element = lookupTable.get(value);
+      if (element == null)
+      {
+         Logger.warning(GaugeColorMode.class.getName(), "Unknown element " + value);
+         return ZONE; // fallback
+      }
+      return element;
+   }
+}
index 3eb22dd..dd3afb6 100644 (file)
@@ -15,8 +15,15 @@ ChartColors_7th=7th:
 ChartColors_8th=8th:
 ChartColors_9th=9th:
 ChartColors_Background=Background color:
+ChartColors_DialCurrValueBkgndColor=Dial current value background color:
+ChartColors_DialCurrValueTextColor=Dial current value text color:
+ChartColors_DialNeedleColor=Dial needle color:
+ChartColors_DialNeedlePinColor=Dial needle pin color:
+ChartColors_DialScaleColor=Dial scale color:
+ChartColors_DialScaleTextColor=Dial scale text color:
 ChartColors_GridX=X axis grid color:
 ChartColors_GridY=Y axis grid color:
+ChartColors_LegendTextColor=Legend text color:
 ChartColors_LineColors=Line colors
 ChartColors_PlotArea=Plot area background color:
 ChartColors_TickX=X axis tick color:
index 7198f80..fcb0ef1 100644 (file)
@@ -15,8 +15,15 @@ ChartColors_7th=7.
 ChartColors_8th=8.
 ChartColors_9th=9.
 ChartColors_Background=Barva pozad\u00ED\:
+ChartColors_DialCurrValueBkgndColor=Dial current value background color:
+ChartColors_DialCurrValueTextColor=Dial current value text color:
+ChartColors_DialNeedleColor=Dial needle color:
+ChartColors_DialNeedlePinColor=Dial needle pin color:
+ChartColors_DialScaleColor=Dial scale color:
+ChartColors_DialScaleTextColor=Dial scale text color:
 ChartColors_GridX=Barva m\u0159\u00ED\u017Eky na ose X\:
 ChartColors_GridY=Barva m\u0159\u00ED\u017Eky na ose Y\:
+ChartColors_LegendTextColor=Legend text color:
 ChartColors_LineColors=Barva linek
 ChartColors_PlotArea=Pozad\u00ED oblasti grafu\:
 ChartColors_TickX=Barva na ose X\:
index 3eb22dd..dd3afb6 100644 (file)
@@ -15,8 +15,15 @@ ChartColors_7th=7th:
 ChartColors_8th=8th:
 ChartColors_9th=9th:
 ChartColors_Background=Background color:
+ChartColors_DialCurrValueBkgndColor=Dial current value background color:
+ChartColors_DialCurrValueTextColor=Dial current value text color:
+ChartColors_DialNeedleColor=Dial needle color:
+ChartColors_DialNeedlePinColor=Dial needle pin color:
+ChartColors_DialScaleColor=Dial scale color:
+ChartColors_DialScaleTextColor=Dial scale text color:
 ChartColors_GridX=X axis grid color:
 ChartColors_GridY=Y axis grid color:
+ChartColors_LegendTextColor=Legend text color:
 ChartColors_LineColors=Line colors
 ChartColors_PlotArea=Plot area background color:
 ChartColors_TickX=X axis tick color:
index 9635ede..2ec2cad 100644 (file)
@@ -15,8 +15,15 @@ ChartColors_7th=7\u00ba:
 ChartColors_8th=8\u00ba:
 ChartColors_9th=9\u00ba:
 ChartColors_Background=Color de fondo:
+ChartColors_DialCurrValueBkgndColor=Dial current value background color:
+ChartColors_DialCurrValueTextColor=Dial current value text color:
+ChartColors_DialNeedleColor=Dial needle color:
+ChartColors_DialNeedlePinColor=Dial needle pin color:
+ChartColors_DialScaleColor=Dial scale color:
+ChartColors_DialScaleTextColor=Dial scale text color:
 ChartColors_GridX=Color para la cuadr\u00edcula del eje X:
 ChartColors_GridY=Color para la cuadr\u00edcula del eje y:
+ChartColors_LegendTextColor=Legend text color:
 ChartColors_LineColors=Color para la l\u00ednea
 ChartColors_PlotArea=Color de fondo para el \u00e1rea de trazado:
 ChartColors_TickX=Color para las marcas del eje X:
index 3eb22dd..dd3afb6 100644 (file)
@@ -15,8 +15,15 @@ ChartColors_7th=7th:
 ChartColors_8th=8th:
 ChartColors_9th=9th:
 ChartColors_Background=Background color:
+ChartColors_DialCurrValueBkgndColor=Dial current value background color:
+ChartColors_DialCurrValueTextColor=Dial current value text color:
+ChartColors_DialNeedleColor=Dial needle color:
+ChartColors_DialNeedlePinColor=Dial needle pin color:
+ChartColors_DialScaleColor=Dial scale color:
+ChartColors_DialScaleTextColor=Dial scale text color:
 ChartColors_GridX=X axis grid color:
 ChartColors_GridY=Y axis grid color:
+ChartColors_LegendTextColor=Legend text color:
 ChartColors_LineColors=Line colors
 ChartColors_PlotArea=Plot area background color:
 ChartColors_TickX=X axis tick color:
index 60074dd..c0e7258 100644 (file)
@@ -15,8 +15,15 @@ ChartColors_7th=7-\u0439:
 ChartColors_8th=8-\u0439:
 ChartColors_9th=9-\u0439:
 ChartColors_Background=\u0426\u0432\u0435\u0442 \u0444\u043e\u043d\u0430:
+ChartColors_DialCurrValueBkgndColor=Dial current value background color:
+ChartColors_DialCurrValueTextColor=Dial current value text color:
+ChartColors_DialNeedleColor=Dial needle color:
+ChartColors_DialNeedlePinColor=Dial needle pin color:
+ChartColors_DialScaleColor=Dial scale color:
+ChartColors_DialScaleTextColor=Dial scale text color:
 ChartColors_GridX=\u0426\u0432\u0435\u0442 \u0441\u0435\u0442\u043a\u0438 \u043f\u043e \u043e\u0441\u0438 X:
 ChartColors_GridY=\u0426\u0432\u0435\u0442 \u0441\u0435\u0442\u043a\u0438 \u043f\u043e \u043e\u0441\u0438 Y:
+ChartColors_LegendTextColor=Legend text color:
 ChartColors_LineColors=\u0426\u0432\u0435\u0442\u0430 \u043b\u0438\u043d\u0438\u0438
 ChartColors_PlotArea=\u0426\u0432\u0435\u0442 \u0437\u0430\u043b\u0438\u0432\u043a\u0438 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u044b:
 ChartColors_TickX=\u0426\u0432\u0435\u0442 \u043e\u0442\u043c\u0435\u0442\u043e\u043a \u043f\u043e \u043e\u0441\u0438 X:
index 3eb22dd..dd3afb6 100644 (file)
@@ -15,8 +15,15 @@ ChartColors_7th=7th:
 ChartColors_8th=8th:
 ChartColors_9th=9th:
 ChartColors_Background=Background color:
+ChartColors_DialCurrValueBkgndColor=Dial current value background color:
+ChartColors_DialCurrValueTextColor=Dial current value text color:
+ChartColors_DialNeedleColor=Dial needle color:
+ChartColors_DialNeedlePinColor=Dial needle pin color:
+ChartColors_DialScaleColor=Dial scale color:
+ChartColors_DialScaleTextColor=Dial scale text color:
 ChartColors_GridX=X axis grid color:
 ChartColors_GridY=Y axis grid color:
+ChartColors_LegendTextColor=Legend text color:
 ChartColors_LineColors=Line colors
 ChartColors_PlotArea=Plot area background color:
 ChartColors_TickX=X axis tick color:
index ceb8724..c8fbfa4 100644 (file)
@@ -93,17 +93,28 @@ public class CurrentValueWidget extends GaugeWidget
                final String value = getValueAsDisplayString(dci);
                final Font font = WidgetHelper.getBestFittingFont(gc, valueFonts, value, rect.width, rect.height); //$NON-NLS-1$
                gc.setFont(font);
-               if ((dci.getValue() <= leftRedZone) || (dci.getValue() >= rightRedZone))
+               switch(colorMode)
                {
-                       gc.setForeground(colors.create(RED_ZONE_COLOR));
-               }
-               else if ((dci.getValue() <= leftYellowZone) || (dci.getValue() >= rightYellowZone))
-               {
-                       gc.setForeground(colors.create(YELLOW_ZONE_COLOR));
-               }
-               else
-               {
-                       gc.setForeground(colors.create(GREEN_ZONE_COLOR));
+                  case ZONE:
+               if ((dci.getValue() <= leftRedZone) || (dci.getValue() >= rightRedZone))
+               {
+                       gc.setForeground(colors.create(RED_ZONE_COLOR));
+               }
+               else if ((dci.getValue() <= leftYellowZone) || (dci.getValue() >= rightYellowZone))
+               {
+                       gc.setForeground(colors.create(YELLOW_ZONE_COLOR));
+               }
+               else
+               {
+                       gc.setForeground(colors.create(GREEN_ZONE_COLOR));
+               }
+               break;
+                  case CUSTOM:
+                  gc.setForeground(colors.create(customColor));
+                  break;
+         default:
+            gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_BLACK));
+            break;
                }
                Point ext = gc.textExtent(value);
                gc.drawText(value, rect.x + rect.width / 2 - ext.x / 2, rect.y + rect.height / 2 - ext.y / 2);
index 5a9012e..650c504 100644 (file)
@@ -121,12 +121,22 @@ public class DialChartWidget extends GaugeWidget
                gc.fillArc(rect.x, rect.y, rect.width, rect.height, 0, 360);
                
                // Draw zones
-               int startAngle = 225;
-               startAngle = drawZone(gc, rect, cx, cy, startAngle, minValue, leftRedZone, angleValue, RED_ZONE_COLOR);
-               startAngle = drawZone(gc, rect, cx, cy, startAngle, leftRedZone, leftYellowZone, angleValue, YELLOW_ZONE_COLOR);
-               startAngle = drawZone(gc, rect, cx, cy, startAngle, leftYellowZone, rightYellowZone, angleValue, GREEN_ZONE_COLOR);
-               startAngle = drawZone(gc, rect, cx, cy, startAngle, rightYellowZone, rightRedZone, angleValue, YELLOW_ZONE_COLOR);
-               startAngle = drawZone(gc, rect, cx, cy, startAngle, rightRedZone, maxValue, angleValue, RED_ZONE_COLOR);
+               switch(colorMode)
+               {
+                  case ZONE:
+                     int startAngle = 225;
+                     startAngle = drawZone(gc, rect, cx, cy, startAngle, minValue, leftRedZone, angleValue, RED_ZONE_COLOR);
+                     startAngle = drawZone(gc, rect, cx, cy, startAngle, leftRedZone, leftYellowZone, angleValue, YELLOW_ZONE_COLOR);
+                     startAngle = drawZone(gc, rect, cx, cy, startAngle, leftYellowZone, rightYellowZone, angleValue, GREEN_ZONE_COLOR);
+                     startAngle = drawZone(gc, rect, cx, cy, startAngle, rightYellowZone, rightRedZone, angleValue, YELLOW_ZONE_COLOR);
+                     startAngle = drawZone(gc, rect, cx, cy, startAngle, rightRedZone, maxValue, angleValue, RED_ZONE_COLOR);
+                     break;
+                  case CUSTOM:
+            drawZone(gc, rect, cx, cy, 225, minValue, maxValue, angleValue, customColor);
+                     break;
+                  default:
+                     break;
+               }
                
                // Draw center part and border
                gc.setBackground(getColorFromPreferences("Chart.Colors.PlotArea")); //$NON-NLS-1$
index 1b0a1db..e1128ff 100644 (file)
@@ -41,6 +41,7 @@ import org.netxms.client.datacollection.Threshold;
 import org.netxms.ui.eclipse.charts.Activator;
 import org.netxms.ui.eclipse.charts.api.ChartColor;
 import org.netxms.ui.eclipse.charts.api.Gauge;
+import org.netxms.ui.eclipse.charts.api.GaugeColorMode;
 import org.netxms.ui.eclipse.charts.widgets.internal.DataComparisonElement;
 import org.netxms.ui.eclipse.tools.ColorCache;
 
@@ -49,29 +50,31 @@ import org.netxms.ui.eclipse.tools.ColorCache;
  */
 public abstract class GaugeWidget extends GenericChart implements Gauge, PaintListener, DisposeListener
 {
-       protected static final int OUTER_MARGIN_WIDTH = 5;
-       protected static final int OUTER_MARGIN_HEIGHT = 5;
-       protected static final int INNER_MARGIN_WIDTH = 5;
-       protected static final int INNER_MARGIN_HEIGHT = 5;
-       
-       protected static final RGB GREEN_ZONE_COLOR = new RGB(0, 224, 0);
-       protected static final RGB YELLOW_ZONE_COLOR = new RGB(255, 242, 0);
-       protected static final RGB RED_ZONE_COLOR = new RGB(224, 0, 0);
-       
-       protected List<DataComparisonElement> parameters = new ArrayList<DataComparisonElement>(MAX_CHART_ITEMS);
-       protected Image chartImage = null;
-       protected ColorCache colors;
-       protected double minValue = 0.0;
-       protected double maxValue = 100.0;
-       protected double leftRedZone = 0.0;
-       protected double leftYellowZone = 0.0;
-       protected double rightYellowZone = 70.0;
-       protected double rightRedZone = 90.0;
-       protected boolean vertical = false;
-       protected boolean legendInside = true;
-       protected boolean gridVisible = true;
-       protected boolean elementBordersVisible = false;
-       protected String fontName = "Verdana"; //$NON-NLS-1$
+   protected static final int OUTER_MARGIN_WIDTH = 5;
+   protected static final int OUTER_MARGIN_HEIGHT = 5;
+   protected static final int INNER_MARGIN_WIDTH = 5;
+   protected static final int INNER_MARGIN_HEIGHT = 5;
+
+   protected static final RGB GREEN_ZONE_COLOR = new RGB(0, 224, 0);
+   protected static final RGB YELLOW_ZONE_COLOR = new RGB(255, 242, 0);
+   protected static final RGB RED_ZONE_COLOR = new RGB(224, 0, 0);
+
+   protected List<DataComparisonElement> parameters = new ArrayList<DataComparisonElement>(MAX_CHART_ITEMS);
+   protected Image chartImage = null;
+   protected ColorCache colors;
+   protected double minValue = 0.0;
+   protected double maxValue = 100.0;
+   protected double leftRedZone = 0.0;
+   protected double leftYellowZone = 0.0;
+   protected double rightYellowZone = 70.0;
+   protected double rightRedZone = 90.0;
+   protected boolean vertical = false;
+   protected boolean legendInside = true;
+   protected boolean gridVisible = true;
+   protected boolean elementBordersVisible = false;
+   protected String fontName = "Verdana"; //$NON-NLS-1$
+   protected GaugeColorMode colorMode = GaugeColorMode.ZONE;
+   protected RGB customColor = new RGB(0, 0, 0);
        
        private boolean fontsCreated = false;
        
@@ -116,99 +119,99 @@ public abstract class GaugeWidget extends GenericChart implements Gauge, PaintLi
        protected abstract void disposeFonts();
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.DataChart#initializationComplete()
-        */
-       @Override
-       public void initializationComplete()
-       {
-       }
+    * @see org.netxms.ui.eclipse.charts.api.DataChart#initializationComplete()
+    */
+   @Override
+   public void initializationComplete()
+   {
+   }
 
    /**
-        * Create color object from preference string
-        *  
-        * @param name Preference name
-        * @return Color object
-        */
-       protected Color getColorFromPreferences(final String name)
-       {
-               return colors.create(PreferenceConverter.getColor(preferenceStore, name));
-       }
+    * Create color object from preference string
+    * 
+    * @param name Preference name
+    * @return Color object
+    */
+   protected Color getColorFromPreferences(final String name)
+   {
+      return colors.create(PreferenceConverter.getColor(preferenceStore, name));
+   }
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.DataChart#setChartTitle(java.lang.String)
-        */
-       @Override
-       public void setChartTitle(String title)
-       {
-               this.title = title;
-               refresh();
-       }
+    * @see org.netxms.ui.eclipse.charts.api.DataChart#setChartTitle(java.lang.String)
+    */
+   @Override
+   public void setChartTitle(String title)
+   {
+      this.title = title;
+      refresh();
+   }
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.DataChart#setTitleVisible(boolean)
-        */
-       @Override
-       public void setTitleVisible(boolean visible)
-       {
-               titleVisible = visible;
-               refresh();
-       }
+    * @see org.netxms.ui.eclipse.charts.api.DataChart#setTitleVisible(boolean)
+    */
+   @Override
+   public void setTitleVisible(boolean visible)
+   {
+      titleVisible = visible;
+      refresh();
+   }
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.DataChart#setLegendVisible(boolean)
-        */
-       @Override
-       public void setLegendVisible(boolean visible)
-       {
-               legendVisible = visible;
-               refresh();
-       }
+    * @see org.netxms.ui.eclipse.charts.api.DataChart#setLegendVisible(boolean)
+    */
+   @Override
+   public void setLegendVisible(boolean visible)
+   {
+      legendVisible = visible;
+      refresh();
+   }
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.DataChart#set3DModeEnabled(boolean)
-        */
-       @Override
-       public void set3DModeEnabled(boolean enabled)
-       {
-               displayIn3D = enabled;
-               refresh();
-       }
+    * @see org.netxms.ui.eclipse.charts.api.DataChart#set3DModeEnabled(boolean)
+    */
+   @Override
+   public void set3DModeEnabled(boolean enabled)
+   {
+      displayIn3D = enabled;
+      refresh();
+   }
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.DataChart#setLogScaleEnabled(boolean)
-        */
-       @Override
-       public void setLogScaleEnabled(boolean enabled)
-       {
-       }
+    * @see org.netxms.ui.eclipse.charts.api.DataChart#setLogScaleEnabled(boolean)
+    */
+   @Override
+   public void setLogScaleEnabled(boolean enabled)
+   {
+   }
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.DataComparisonChart#addParameter(org.netxms.client.datacollection.GraphItem, double)
-        */
-       @Override
-       public int addParameter(GraphItem dci, double value)
-       {
+    * @see org.netxms.ui.eclipse.charts.api.DataComparisonChart#addParameter(org.netxms.client.datacollection.GraphItem, double)
+    */
+   @Override
+   public int addParameter(GraphItem dci, double value)
+   {
       parameters.add(new DataComparisonElement(dci, value, null));
-               return parameters.size() - 1;
-       }
+      return parameters.size() - 1;
+   }
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.DataComparisonChart#updateParameter(int, double, boolean)
-        */
-       @Override
-       public void updateParameter(int index, double value, boolean updateChart)
-       {
-               try
-               {
+    * @see org.netxms.ui.eclipse.charts.api.DataComparisonChart#updateParameter(int, double, boolean)
+    */
+   @Override
+   public void updateParameter(int index, double value, boolean updateChart)
+   {
+      try
+      {
                        parameters.get(index).setValue(value);
-               }
-               catch(IndexOutOfBoundsException e)
-               {
-               }
+      }
+      catch(IndexOutOfBoundsException e)
+      {
+      }
 
-               if (updateChart)
-                       refresh();
-       }
+      if (updateChart)
+         refresh();
+   }
 
    /*
     * (non-Javadoc)
@@ -239,106 +242,106 @@ public abstract class GaugeWidget extends GenericChart implements Gauge, PaintLi
     * 
     * @see org.netxms.ui.eclipse.charts.api.DataComparisonChart#updateParameterThresholds(int,
     * org.netxms.client.datacollection.Threshold[])
-        */
-       @Override
-       public void updateParameterThresholds(int index, Threshold[] thresholds)
-       {
-       }
+    */
+   @Override
+   public void updateParameterThresholds(int index, Threshold[] thresholds)
+   {
+   }
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.DataComparisonChart#setChartType(int)
-        */
-       @Override
-       public void setChartType(int chartType)
-       {
-       }
+    * @see org.netxms.ui.eclipse.charts.api.DataComparisonChart#setChartType(int)
+    */
+   @Override
+   public void setChartType(int chartType)
+   {
+   }
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.DataComparisonChart#getChartType()
-        */
-       @Override
-       public int getChartType()
-       {
-               return GAUGE_CHART;
-       }
+    * @see org.netxms.ui.eclipse.charts.api.DataComparisonChart#getChartType()
+    */
+   @Override
+   public int getChartType()
+   {
+      return GAUGE_CHART;
+   }
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.DataComparisonChart#setTransposed(boolean)
-        */
-       @Override
-       public void setTransposed(boolean transposed)
-       {
-       }
+    * @see org.netxms.ui.eclipse.charts.api.DataComparisonChart#setTransposed(boolean)
+    */
+   @Override
+   public void setTransposed(boolean transposed)
+   {
+   }
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.DataComparisonChart#isTransposed()
-        */
-       @Override
-       public boolean isTransposed()
-       {
-               return false;
-       }
+    * @see org.netxms.ui.eclipse.charts.api.DataComparisonChart#isTransposed()
+    */
+   @Override
+   public boolean isTransposed()
+   {
+      return false;
+   }
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.DataComparisonChart#setLabelsVisible(boolean)
-        */
-       @Override
-       public void setLabelsVisible(boolean visible)
-       {
-       }
+    * @see org.netxms.ui.eclipse.charts.api.DataComparisonChart#setLabelsVisible(boolean)
+    */
+   @Override
+   public void setLabelsVisible(boolean visible)
+   {
+   }
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.DataComparisonChart#isLabelsVisible()
-        */
-       @Override
-       public boolean isLabelsVisible()
-       {
-               return false;
-       }
+    * @see org.netxms.ui.eclipse.charts.api.DataComparisonChart#isLabelsVisible()
+    */
+   @Override
+   public boolean isLabelsVisible()
+   {
+      return false;
+   }
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.DataComparisonChart#setRotation(double)
-        */
-       @Override
-       public void setRotation(double angle)
-       {
-       }
+    * @see org.netxms.ui.eclipse.charts.api.DataComparisonChart#setRotation(double)
+    */
+   @Override
+   public void setRotation(double angle)
+   {
+   }
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.DataComparisonChart#getRotation()
-        */
-       @Override
-       public double getRotation()
-       {
-               return 0;
-       }
+    * @see org.netxms.ui.eclipse.charts.api.DataComparisonChart#getRotation()
+    */
+   @Override
+   public double getRotation()
+   {
+      return 0;
+   }
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.DataChart#refresh()
-        */
-       @Override
-       public void refresh()
-       {
-               redraw();
-       }
-       
+    * @see org.netxms.ui.eclipse.charts.api.DataChart#refresh()
+    */
+   @Override
+   public void refresh()
+   {
+      redraw();
+   }
+
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.DataChart#rebuild()
-        */
-       @Override
-       public void rebuild()
-       {
-               redraw();
-       }
+    * @see org.netxms.ui.eclipse.charts.api.DataChart#rebuild()
+    */
+   @Override
+   public void rebuild()
+   {
+      redraw();
+   }
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.DataChart#hasAxes()
-        */
-       @Override
-       public boolean hasAxes()
-       {
-               return false;
-       }
+    * @see org.netxms.ui.eclipse.charts.api.DataChart#hasAxes()
+    */
+   @Override
+   public boolean hasAxes()
+   {
+      return false;
+   }
 
        /* (non-Javadoc)
         * @see org.eclipse.swt.events.PaintListener#paintControl(org.eclipse.swt.events.PaintEvent)
@@ -403,327 +406,378 @@ public abstract class GaugeWidget extends GenericChart implements Gauge, PaintLi
                        return;
                }
                
-               if (vertical)
-               {
-                       int w = (size.x - OUTER_MARGIN_WIDTH * 2);
-                       int h = (size.y - OUTER_MARGIN_HEIGHT - top) / parameters.size();
-                       if ((w > 40) && (h > 40 * parameters.size()))
-                       {
-                               for(int i = 0; i < parameters.size(); i++)
-                               {
-                                       renderElement(gc, parameters.get(i), 0, top + i * h, w, h);
-                               }
-                       }
-               }
-               else
-               {
-                       int w = (size.x - OUTER_MARGIN_WIDTH * 2) / parameters.size();
-                       int h = size.y - OUTER_MARGIN_HEIGHT - top;
-                       if ((w > 40 * parameters.size()) && (h > 40))
-                       {
-                               for(int i = 0; i < parameters.size(); i++)
-                               {
-                                       renderElement(gc, parameters.get(i), i * w, top, w, h);
-                               }
-                       }
-               }
-               
-               gc.dispose();
-       }
+      if (vertical)
+      {
+         int w = (size.x - OUTER_MARGIN_WIDTH * 2);
+         int h = (size.y - OUTER_MARGIN_HEIGHT - top) / parameters.size();
+         Point minSize = getMinElementSize();
+         if ((w >= minSize.x) && (h >= minSize.x))
+         {
+            for(int i = 0; i < parameters.size(); i++)
+            {
+               renderElement(gc, parameters.get(i), 0, top + i * h, w, h);
+            }
+         }
+      }
+      else
+      {
+         int w = (size.x - OUTER_MARGIN_WIDTH * 2) / parameters.size();
+         int h = size.y - OUTER_MARGIN_HEIGHT - top;
+         Point minSize = getMinElementSize();
+         if ((w >= minSize.x) && (h >= minSize.x))
+         {
+            for(int i = 0; i < parameters.size(); i++)
+            {
+               renderElement(gc, parameters.get(i), i * w, top, w, h);
+            }
+         }
+      }
 
-       /**
-        * @param dataComparisonElement
-        * @param i
-        * @param w
-        */
-       protected abstract void renderElement(GC gc, DataComparisonElement dci, int x, int y, int w, int h);
+      gc.dispose();
+   }
+   
+   /**
+    * Get minimal element size
+    * 
+    * @return
+    */
+   protected Point getMinElementSize()
+   {
+      return new Point(10, 10);
+   }
 
-       /**
-        * @param dci
-        * @return
-        */
-       protected String getValueAsDisplayString(DataComparisonElement dci)
-       {
-               switch(dci.getObject().getDataType())
-               {
-                       case DataCollectionItem.DT_INT:
-                               return Integer.toString((int)dci.getValue());
-                       case DataCollectionItem.DT_UINT:
-                       case DataCollectionItem.DT_INT64:
-                       case DataCollectionItem.DT_UINT64:
-                               return Long.toString((long)dci.getValue());
-               case DataCollectionItem.DT_STRING:
-               return dci.getRawValue();
-                       default:
-                               return Double.toString(dci.getValue());
-               }
-       }
+   /**
+    * @param dataComparisonElement
+    * @param i
+    * @param w
+    */
+   protected abstract void renderElement(GC gc, DataComparisonElement dci, int x, int y, int w, int h);
+
+   /**
+    * @param dci
+    * @return
+    */
+   protected String getValueAsDisplayString(DataComparisonElement dci)
+   {
+      switch(dci.getObject().getDataType())
+      {
+         case DataCollectionItem.DT_INT:
+            return Integer.toString((int)dci.getValue());
+         case DataCollectionItem.DT_UINT:
+         case DataCollectionItem.DT_INT64:
+         case DataCollectionItem.DT_UINT64:
+            return Long.toString((long)dci.getValue());
+         case DataCollectionItem.DT_STRING:
+            return dci.getRawValue();
+         default:
+            return Double.toString(dci.getValue());
+      }
+   }
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.DialChart#getMinValue()
-        */
-       @Override
-       public double getMinValue()
-       {
-               return minValue;
-       }
+    * @see org.netxms.ui.eclipse.charts.api.DialChart#getMinValue()
+    */
+   @Override
+   public double getMinValue()
+   {
+      return minValue;
+   }
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.DialChart#setMinValue(double)
-        */
-       @Override
-       public void setMinValue(double minValue)
-       {
-               this.minValue = minValue;
-       }
+    * @see org.netxms.ui.eclipse.charts.api.DialChart#setMinValue(double)
+    */
+   @Override
+   public void setMinValue(double minValue)
+   {
+      this.minValue = minValue;
+   }
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.DialChart#getMaxValue()
-        */
-       @Override
-       public double getMaxValue()
-       {
-               return maxValue;
-       }
+    * @see org.netxms.ui.eclipse.charts.api.DialChart#getMaxValue()
+    */
+   @Override
+   public double getMaxValue()
+   {
+      return maxValue;
+   }
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.DialChart#setMaxValue(double)
-        */
-       @Override
-       public void setMaxValue(double maxValue)
-       {
-               this.maxValue = maxValue;
-       }
+    * @see org.netxms.ui.eclipse.charts.api.DialChart#setMaxValue(double)
+    */
+   @Override
+   public void setMaxValue(double maxValue)
+   {
+      this.maxValue = maxValue;
+   }
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.DialChart#getLeftRedZone()
-        */
-       @Override
-       public double getLeftRedZone()
-       {
-               return leftRedZone;
-       }
+    * @see org.netxms.ui.eclipse.charts.api.DialChart#getLeftRedZone()
+    */
+   @Override
+   public double getLeftRedZone()
+   {
+      return leftRedZone;
+   }
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.DialChart#setLeftRedZone(double)
-        */
-       @Override
-       public void setLeftRedZone(double leftRedZone)
-       {
-               this.leftRedZone = leftRedZone;
-       }
+    * @see org.netxms.ui.eclipse.charts.api.DialChart#setLeftRedZone(double)
+    */
+   @Override
+   public void setLeftRedZone(double leftRedZone)
+   {
+      this.leftRedZone = leftRedZone;
+   }
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.DialChart#getLeftYellowZone()
-        */
-       @Override
-       public double getLeftYellowZone()
-       {
-               return leftYellowZone;
-       }
+    * @see org.netxms.ui.eclipse.charts.api.DialChart#getLeftYellowZone()
+    */
+   @Override
+   public double getLeftYellowZone()
+   {
+      return leftYellowZone;
+   }
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.DialChart#setLeftYellowZone(double)
-        */
-       @Override
-       public void setLeftYellowZone(double leftYellowZone)
-       {
-               this.leftYellowZone = leftYellowZone;
-       }
+    * @see org.netxms.ui.eclipse.charts.api.DialChart#setLeftYellowZone(double)
+    */
+   @Override
+   public void setLeftYellowZone(double leftYellowZone)
+   {
+      this.leftYellowZone = leftYellowZone;
+   }
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.DialChart#getRightYellowZone()
-        */
-       @Override
-       public double getRightYellowZone()
-       {
-               return rightYellowZone;
-       }
+    * @see org.netxms.ui.eclipse.charts.api.DialChart#getRightYellowZone()
+    */
+   @Override
+   public double getRightYellowZone()
+   {
+      return rightYellowZone;
+   }
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.DialChart#setRightYellowZone(double)
-        */
-       @Override
-       public void setRightYellowZone(double rightYellowZone)
-       {
-               this.rightYellowZone = rightYellowZone;
-       }
+    * @see org.netxms.ui.eclipse.charts.api.DialChart#setRightYellowZone(double)
+    */
+   @Override
+   public void setRightYellowZone(double rightYellowZone)
+   {
+      this.rightYellowZone = rightYellowZone;
+   }
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.DialChart#getRightRedZone()
-        */
-       @Override
-       public double getRightRedZone()
-       {
-               return rightRedZone;
-       }
+    * @see org.netxms.ui.eclipse.charts.api.DialChart#getRightRedZone()
+    */
+   @Override
+   public double getRightRedZone()
+   {
+      return rightRedZone;
+   }
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.DialChart#setRightRedZone(double)
-        */
-       @Override
-       public void setRightRedZone(double rightRedZone)
-       {
-               this.rightRedZone = rightRedZone;
-       }
+    * @see org.netxms.ui.eclipse.charts.api.DialChart#setRightRedZone(double)
+    */
+   @Override
+   public void setRightRedZone(double rightRedZone)
+   {
+      this.rightRedZone = rightRedZone;
+   }
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.DialChart#isLegendInside()
-        */
-       @Override
-       public boolean isLegendInside()
-       {
-               return legendInside;
-       }
+    * @see org.netxms.ui.eclipse.charts.api.DialChart#isLegendInside()
+    */
+   @Override
+   public boolean isLegendInside()
+   {
+      return legendInside;
+   }
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.DialChart#setLegendInside(boolean)
-        */
-       @Override
-       public void setLegendInside(boolean legendInside)
-       {
-               this.legendInside = legendInside;
-       }
+    * @see org.netxms.ui.eclipse.charts.api.DialChart#setLegendInside(boolean)
+    */
+   @Override
+   public void setLegendInside(boolean legendInside)
+   {
+      this.legendInside = legendInside;
+   }
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.DataChart#isGridVisible()
-        */
-       @Override
-       public boolean isGridVisible()
-       {
-               return gridVisible;
-       }
+    * @see org.netxms.ui.eclipse.charts.api.DataChart#isGridVisible()
+    */
+   @Override
+   public boolean isGridVisible()
+   {
+      return gridVisible;
+   }
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.DataChart#setGridVisible(boolean)
-        */
-       @Override
-       public void setGridVisible(boolean visible)
-       {
-               gridVisible = visible;
-       }
+    * @see org.netxms.ui.eclipse.charts.api.DataChart#setGridVisible(boolean)
+    */
+   @Override
+   public void setGridVisible(boolean visible)
+   {
+      gridVisible = visible;
+   }
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.DataChart#setBackgroundColor(org.netxms.ui.eclipse.charts.api.ChartColor)
-        */
-       @Override
-       public void setBackgroundColor(ChartColor color)
-       {
-       }
+    * @see org.netxms.ui.eclipse.charts.api.DataChart#setBackgroundColor(org.netxms.ui.eclipse.charts.api.ChartColor)
+    */
+   @Override
+   public void setBackgroundColor(ChartColor color)
+   {
+   }
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.DataChart#setPlotAreaColor(org.netxms.ui.eclipse.charts.api.ChartColor)
-        */
-       @Override
-       public void setPlotAreaColor(ChartColor color)
-       {
-       }
+    * @see org.netxms.ui.eclipse.charts.api.DataChart#setPlotAreaColor(org.netxms.ui.eclipse.charts.api.ChartColor)
+    */
+   @Override
+   public void setPlotAreaColor(ChartColor color)
+   {
+   }
 
        /* (non-Javadoc)
         * @see org.netxms.ui.eclipse.charts.api.DataChart#setLegendColor(org.netxms.ui.eclipse.charts.api.ChartColor, org.netxms.ui.eclipse.charts.api.ChartColor)
-        */
-       @Override
-       public void setLegendColor(ChartColor foreground, ChartColor background)
-       {
-       }
+    */
+   @Override
+   public void setLegendColor(ChartColor foreground, ChartColor background)
+   {
+   }
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.DataChart#setAxisColor(org.netxms.ui.eclipse.charts.api.ChartColor)
-        */
-       @Override
-       public void setAxisColor(ChartColor color)
-       {
-       }
+    * @see org.netxms.ui.eclipse.charts.api.DataChart#setAxisColor(org.netxms.ui.eclipse.charts.api.ChartColor)
+    */
+   @Override
+   public void setAxisColor(ChartColor color)
+   {
+   }
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.DataChart#setGridColor(org.netxms.ui.eclipse.charts.api.ChartColor)
-        */
-       @Override
-       public void setGridColor(ChartColor color)
-       {
-       }
+    * @see org.netxms.ui.eclipse.charts.api.DataChart#setGridColor(org.netxms.ui.eclipse.charts.api.ChartColor)
+    */
+   @Override
+   public void setGridColor(ChartColor color)
+   {
+   }
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.DataChart#addError(java.lang.String)
-        */
-       @Override
-       public void addError(String message)
-       {
-       }
+    * @see org.netxms.ui.eclipse.charts.api.DataChart#addError(java.lang.String)
+    */
+   @Override
+   public void addError(String message)
+   {
+   }
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.DataChart#clearErrors()
-        */
-       @Override
-       public void clearErrors()
-       {
-       }
+    * @see org.netxms.ui.eclipse.charts.api.DataChart#clearErrors()
+    */
+   @Override
+   public void clearErrors()
+   {
+   }
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.DialChart#isVertical()
-        */
-       @Override
-       public boolean isVertical()
-       {
-               return vertical;
-       }
+    * @see org.netxms.ui.eclipse.charts.api.DialChart#isVertical()
+    */
+   @Override
+   public boolean isVertical()
+   {
+      return vertical;
+   }
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.DialChart#setVertical(boolean)
-        */
-       @Override
-       public void setVertical(boolean vertical)
-       {
-               this.vertical = vertical;
-       }
+    * @see org.netxms.ui.eclipse.charts.api.DialChart#setVertical(boolean)
+    */
+   @Override
+   public void setVertical(boolean vertical)
+   {
+      this.vertical = vertical;
+   }
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.Gauge#isElementBordersVisible()
-        */
-       @Override
+    * @see org.netxms.ui.eclipse.charts.api.Gauge#isElementBordersVisible()
+    */
+   @Override
    public boolean isElementBordersVisible()
    {
       return elementBordersVisible;
    }
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.Gauge#setElementBordersVisible(boolean)
-        */
-       @Override
+    * @see org.netxms.ui.eclipse.charts.api.Gauge#setElementBordersVisible(boolean)
+    */
+   @Override
    public void setElementBordersVisible(boolean elementBordersVisible)
    {
       this.elementBordersVisible = elementBordersVisible;
    }
 
    /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.Gauge#getFontName()
-        */
-       @Override
-       public String getFontName()
-       {
-               return fontName;
-       }
+    * @see org.netxms.ui.eclipse.charts.api.Gauge#getFontName()
+    */
+   @Override
+   public String getFontName()
+   {
+      return fontName;
+   }
 
        /* (non-Javadoc)
-        * @see org.netxms.ui.eclipse.charts.api.Gauge#setFontName(java.lang.String)
-        */
-       @Override
-       public void setFontName(String fontName)
-       {
-               if ((fontName == null) || fontName.isEmpty())
-                       fontName = "Verdana"; //$NON-NLS-1$
-               if (!fontName.equals(this.fontName))
-               {
-                       this.fontName = fontName;
-                       if (fontsCreated)
-                               disposeFonts();
-                       createFonts();
-                       fontsCreated = true;
-               }
-       }
-       
-         @Override
-          public void setYAxisRange(int from, int to)
-          {
-          }
+    * @see org.netxms.ui.eclipse.charts.api.Gauge#setFontName(java.lang.String)
+    */
+   @Override
+   public void setFontName(String fontName)
+   {
+      if ((fontName == null) || fontName.isEmpty())
+         fontName = "Verdana"; //$NON-NLS-1$
+      if (!fontName.equals(this.fontName))
+      {
+         this.fontName = fontName;
+         if (fontsCreated)
+            disposeFonts();
+         createFonts();
+         fontsCreated = true;
+      }
+   }
+
+   /* (non-Javadoc)
+    * @see org.netxms.ui.eclipse.charts.api.DataChart#setYAxisRange(int, int)
+    */
+   @Override
+   public void setYAxisRange(int from, int to)
+   {
+   }
+
+   /* (non-Javadoc)
+    * @see org.netxms.ui.eclipse.charts.api.Gauge#getColorMode()
+    */
+   @Override
+   public GaugeColorMode getColorMode()
+   {
+      return colorMode;
+   }
+
+   /* (non-Javadoc)
+    * @see org.netxms.ui.eclipse.charts.api.Gauge#setGaugeColorMode(org.netxms.ui.eclipse.charts.api.GaugeColorMode)
+    */
+   @Override
+   public void setColorMode(GaugeColorMode mode)
+   {
+      colorMode = mode;
+   }
+
+   /* (non-Javadoc)
+    * @see org.netxms.ui.eclipse.charts.api.Gauge#getCustomColor()
+    */
+   @Override
+   public RGB getCustomColor()
+   {
+      return customColor;
+   }
+
+   /* (non-Javadoc)
+    * @see org.netxms.ui.eclipse.charts.api.Gauge#setCustomColor(org.eclipse.swt.graphics.RGB)
+    */
+   @Override
+   public void setCustomColor(RGB color)
+   {
+      customColor = color;
+   }
 }
index d0915af..477d3d7 100644 (file)
  */
 package org.netxms.ui.eclipse.dashboard.propertypages;
 
+import org.eclipse.jface.preference.ColorSelector;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Button;
@@ -26,8 +29,10 @@ import org.eclipse.swt.widgets.Combo;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.ui.dialogs.PropertyPage;
+import org.netxms.ui.eclipse.charts.api.GaugeColorMode;
 import org.netxms.ui.eclipse.dashboard.Messages;
 import org.netxms.ui.eclipse.dashboard.widgets.internal.GaugeConfig;
+import org.netxms.ui.eclipse.tools.ColorConverter;
 import org.netxms.ui.eclipse.tools.MessageDialogHelper;
 import org.netxms.ui.eclipse.tools.WidgetHelper;
 import org.netxms.ui.eclipse.widgets.LabeledText;
@@ -49,6 +54,8 @@ public class Gauge extends PropertyPage
        private LabeledText leftRedZone;
        private LabeledText rightYellowZone;
        private LabeledText rightRedZone;
+       private Combo colorMode;
+       private ColorSelector customColor;
 
        /* (non-Javadoc)
         * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
@@ -131,6 +138,33 @@ public class Gauge extends PropertyPage
                gd.horizontalAlignment = SWT.FILL;
                gd.grabExcessHorizontalSpace = true;
                rightRedZone.setLayoutData(gd);
+
+      gd = new GridData();
+      gd.horizontalAlignment = SWT.FILL;
+      gd.grabExcessHorizontalSpace = true;
+      colorMode = WidgetHelper.createLabeledCombo(dialogArea, SWT.READ_ONLY, "Color mode", gd);
+      colorMode.add("Zone color");
+      colorMode.add("Fixed custom color");
+      colorMode.add("Active threshold color");
+      colorMode.select(config.getColorMode());
+      colorMode.addSelectionListener(new SelectionListener() {
+         @Override
+         public void widgetSelected(SelectionEvent e)
+         {
+            onColorModeChange(colorMode.getSelectionIndex());
+         }
+         
+         @Override
+         public void widgetDefaultSelected(SelectionEvent e)
+         {
+            widgetSelected(e);
+         }
+      });
+      
+      gd = new GridData();
+      gd.horizontalAlignment = SWT.LEFT;
+      customColor = WidgetHelper.createLabeledColorSelector(dialogArea, "Custom color", gd); 
+      customColor.setColorValue(ColorConverter.rgbFromInt(config.getCustomColor()));
                
                checkLegendInside = new Button(dialogArea, SWT.CHECK);
                checkLegendInside.setText(Messages.get().DialChart_LegendInside);
@@ -159,6 +193,7 @@ public class Gauge extends PropertyPage
       gd.horizontalSpan = 2;
       checkElementBorders.setLayoutData(gd);
       
+      onColorModeChange(config.getColorMode());
                return dialogArea;
        }
 
@@ -195,6 +230,22 @@ public class Gauge extends PropertyPage
                config.setLegendInside(checkLegendInside.getSelection());
                config.setVertical(checkVertical.getSelection());
                config.setElementBordersVisible(checkElementBorders.getSelection());
+               config.setColorMode(colorMode.getSelectionIndex());
+               config.setCustomColor(ColorConverter.rgbToInt(customColor.getColorValue()));
                return true;
        }
+       
+       /**
+        * Handle color mode change
+        * 
+        * @param newMode
+        */
+       private void onColorModeChange(int newMode)
+       {
+          leftYellowZone.setEnabled(newMode == GaugeColorMode.ZONE.getValue());
+          leftRedZone.setEnabled(newMode == GaugeColorMode.ZONE.getValue());
+      rightYellowZone.setEnabled(newMode == GaugeColorMode.ZONE.getValue());
+      rightRedZone.setEnabled(newMode == GaugeColorMode.ZONE.getValue());
+          customColor.setEnabled(newMode == GaugeColorMode.CUSTOM.getValue());
+       }
 }
index c302118..00fb198 100644 (file)
@@ -26,7 +26,9 @@ import org.netxms.ui.eclipse.charts.api.ChartColor;
 import org.netxms.ui.eclipse.charts.api.ChartDciConfig;
 import org.netxms.ui.eclipse.charts.api.ChartFactory;
 import org.netxms.ui.eclipse.charts.api.Gauge;
+import org.netxms.ui.eclipse.charts.api.GaugeColorMode;
 import org.netxms.ui.eclipse.dashboard.widgets.internal.GaugeConfig;
+import org.netxms.ui.eclipse.tools.ColorConverter;
 
 /**
  * Dial chart element
@@ -77,6 +79,8 @@ public class GaugeElement extends ComparisonChartElement
                ((Gauge)chart).setRightYellowZone(config.getRightYellowZone());
                ((Gauge)chart).setRightRedZone(config.getRightRedZone());
                ((Gauge)chart).setFontName(config.getFontName());
+               ((Gauge)chart).setColorMode(GaugeColorMode.getByValue(config.getColorMode()));
+               ((Gauge)chart).setCustomColor(ColorConverter.rgbFromInt(config.getCustomColor()));
                
                int index = 0;
                for(ChartDciConfig dci : config.getDciList())
index 4b4e8cb..aeed91e 100644 (file)
@@ -3,6 +3,7 @@
  */
 package org.netxms.ui.eclipse.dashboard.widgets.internal;
 
+import org.netxms.ui.eclipse.charts.api.GaugeColorMode;
 import org.simpleframework.xml.Element;
 import org.simpleframework.xml.Serializer;
 import org.simpleframework.xml.core.Persister;
@@ -50,6 +51,12 @@ public class GaugeConfig extends AbstractChartConfig
        @Element(required=false)
        private boolean elementBordersVisible = false;
        
+   @Element(required=false)
+   private int colorMode = GaugeColorMode.ZONE.getValue();
+   
+   @Element(required=false)
+   private int customColor = 0;
+   
        /**
         * Create dial chart settings object from XML document
         * 
@@ -238,4 +245,36 @@ public class GaugeConfig extends AbstractChartConfig
    {
       this.elementBordersVisible = elementBordersVisible;
    }
+
+   /**
+    * @return the colorMode
+    */
+   public int getColorMode()
+   {
+      return colorMode;
+   }
+
+   /**
+    * @param colorMode the colorMode to set
+    */
+   public void setColorMode(int colorMode)
+   {
+      this.colorMode = colorMode;
+   }
+
+   /**
+    * @return the customColor
+    */
+   public int getCustomColor()
+   {
+      return customColor;
+   }
+
+   /**
+    * @param customColor the customColor to set
+    */
+   public void setCustomColor(int customColor)
+   {
+      this.customColor = customColor;
+   }
 }