Skip to content

Package: HistogramGrid

HistogramGrid

nameinstructionbranchcomplexitylinemethod
HistogramGrid()
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
getColor()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
paint(Graphics, Rectangle)
M: 84 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 14 C: 0
0%
M: 1 C: 0
0%
setColor(Color)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
setHSteps(int)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
sethistogramPlotter(XYPlotter)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * *********************************************************************************************************************
3: *
4: * Mistral: open source imaging engine
5: * http://tidalwave.it/projects/mistral
6: *
7: * Copyright (C) 2003 - 2023 by Tidalwave s.a.s. (http://tidalwave.it)
8: *
9: * *********************************************************************************************************************
10: *
11: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
12: * the License. You may obtain a copy of the License at
13: *
14: * http://www.apache.org/licenses/LICENSE-2.0
15: *
16: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
17: * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations under the License.
19: *
20: * *********************************************************************************************************************
21: *
22: * git clone https://bitbucket.org/tidalwave/mistral-src
23: * git clone https://github.com/tidalwave-it/mistral-src
24: *
25: * *********************************************************************************************************************
26: */
27: package it.tidalwave.mistral.example.histogramviewer;
28:
29: import java.awt.Color;
30: import java.awt.Graphics;
31: import java.awt.Graphics2D;
32: import java.awt.Rectangle;
33:
34: /***********************************************************************************************************************
35: *
36: * @author Fabrizio Giudici
37: *
38: **********************************************************************************************************************/
39: public class HistogramGrid
40: {
41: private Color color;
42:
43: private XYPlotter histogramPlotter;
44:
45: private int hSteps = 2;
46:
47: /*******************************************************************************************************************
48: *
49: * @param histogramPlotter
50: *
51: ******************************************************************************************************************/
52: public void sethistogramPlotter (final XYPlotter histogramPlotter)
53: {
54: this.histogramPlotter = histogramPlotter;
55: }
56:
57: /*******************************************************************************************************************
58: *
59: *
60: ******************************************************************************************************************/
61:
62: public void setColor (final Color color)
63: {
64: this.color = color;
65: }
66:
67: /*******************************************************************************************************************
68: *
69: *
70: ******************************************************************************************************************/
71: public Color getColor()
72: {
73: return color;
74: }
75:
76: /*******************************************************************************************************************
77: *
78: * @param hSteps
79: *
80: ******************************************************************************************************************/
81: public void setHSteps (final int hSteps)
82: {
83: this.hSteps = hSteps;
84: }
85:
86: /*******************************************************************************************************************
87: *
88: *
89: ******************************************************************************************************************/
90: public void paint (final Graphics g, final Rectangle bounds)
91: {
92: final var g2 = (Graphics2D)g;
93: g2.setColor(getColor());
94: final var x = bounds.x;
95: final var y = bounds.y;
96: final var w = bounds.width;
97: final var h = bounds.height;
98:
99:• for (var i = 1; i <= hSteps - 1; i++)
100: {
101: var x0 = 0;
102:
103:• if (histogramPlotter.isXAxisLogarithmic())
104: {
105: x0 = x + (i * w) / hSteps;
106: }
107:
108: else
109: {
110: x0 = x + w / (int)(Math.pow(2, i));
111: }
112:
113: g2.drawLine(x0, y, x0, y + h - 1);
114: }
115:
116: g2.drawLine(x, y + h / 2, x + w - 1, y + h / 2);
117: }
118: }