def getColorMap(self, fmax, fmin): # we always draw O(100) gradations...as we don't expect a very large variation theMap = self.createImage(DMVisualization.NO_OF_GRADATIONS+30, 40) stepValue = 0.0; imageGraphics = theMap.getGraphics() j = 0 i = 0.0 imageGraphics.setColor(self.visualizationPanelBD.getBackground()) imageGraphics.fillRect(0, 0, DMVisualization.NO_OF_GRADATIONS+30, 40) imageGraphics.setFont(Font("Sans Serif", Font.ITALIC, 10)) # first shade: stepValue = (10e-5 - self.dmVisualThreashold) / (DMVisualization.NO_OF_GRADATIONS / 6) imageGraphics.setColor(Color(~self.visualizationPanelBD.getBackground().getRGB())) imageGraphics.drawString("10e-6", j, 30) i=self.dmVisualThreashold; j=0 while i<=10e-5: imageGraphics.setColor(self.findInterpolatedColor(fmax, fmin, i)) imageGraphics.drawLine(j, 0, j, 20) i+=stepValue; j+=1 imageGraphics.setColor(Color(~self.visualizationPanelBD.getBackground().getRGB())) # second shade: stepValue = (10e-4 - 10e-5) / (DMVisualization.NO_OF_GRADATIONS / 6) imageGraphics.setColor(Color(~self.visualizationPanelBD.getBackground().getRGB())) imageGraphics.drawString("10e-5", j, 30) i=10e-5 while i<=10e-4: imageGraphics.setColor(self.findInterpolatedColor(fmax, fmin, i)) imageGraphics.drawLine(j, 0, j, 20) i+=stepValue; j+=1 imageGraphics.setColor(Color(~self.visualizationPanelBD.getBackground().getRGB())) imageGraphics.drawString("10e-4", j, 30) # third shade: stepValue = (10e-3 - 10e-4) / (DMVisualization.NO_OF_GRADATIONS / 6) i=10e-4 while i<=10e-3: imageGraphics.setColor(self.findInterpolatedColor(fmax, fmin, i)) imageGraphics.drawLine(j, 0, j, 20) i+=stepValue; j+=1 imageGraphics.setColor(Color(~self.visualizationPanelBD.getBackground().getRGB())) imageGraphics.drawString("10e-3", j, 30) # forth shade: stepValue = (10e-2 - 10e-3) / (DMVisualization.NO_OF_GRADATIONS / 6) i=10e-3 while i<=10e-2: imageGraphics.setColor(self.findInterpolatedColor(fmax, fmin, i)) imageGraphics.drawLine(j, 0, j, 20) i+=stepValue; j+=1 imageGraphics.setColor(Color(~self.visualizationPanelBD.getBackground().getRGB())) imageGraphics.drawString("10e-2", j, 30) # fifth shade: stepValue = (10e-1 - 10e-2) / (DMVisualization.NO_OF_GRADATIONS / 6) i=10e-2 while i<=10e-1: imageGraphics.setColor(self.findInterpolatedColor(fmax, fmin, i)) imageGraphics.drawLine(j, 0, j, 20) i+=stepValue; j+=1 imageGraphics.setColor(Color(~self.visualizationPanelBD.getBackground().getRGB())) imageGraphics.drawString("10e-1", j, 30) # sixth shade: stepValue = (fmax - 10e-1) / (DMVisualization.NO_OF_GRADATIONS / 6) i=10e-1 while i<=fmax: imageGraphics.setColor(self.findInterpolatedColor(fmax, fmin, i)) imageGraphics.drawLine(j, 0, j, 20) i+=stepValue; j+=1 imageGraphics.setColor(Color(~self.visualizationPanelBD.getBackground().getRGB())) imageGraphics.drawString("" + repr(Math.rint(fmax)), j, 30) return theMap;
def round(self, value): return Math.rint(value * self.roundingFactor) / self.roundingFactor