-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GEOS-9026] SLDService built-in color ramps become the more dark, the…
… more classes there are in the ramp
- Loading branch information
Showing
7 changed files
with
110 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...Service/src/main/java/org/geoserver/sldservice/utils/classifier/impl/SingleColorRamp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,48 @@ | |||
package org.geoserver.sldservice.utils.classifier.impl; | |||
|
|||
import java.awt.Color; | |||
import java.util.ArrayList; | |||
import java.util.Collections; | |||
import java.util.List; | |||
import org.geoserver.sldservice.utils.classifier.ColorRamp; | |||
|
|||
public abstract class SingleColorRamp implements ColorRamp { | |||
|
|||
private int classNum = 0; | |||
|
|||
private List<Color> colors = new ArrayList<>(); | |||
|
|||
public int getNumClasses() { | |||
return classNum; | |||
} | |||
|
|||
public void revert() { | |||
Collections.reverse(colors); | |||
} | |||
|
|||
public void setNumClasses(int numClass) { | |||
classNum = numClass; | |||
createRamp(); | |||
} | |||
|
|||
public List<Color> getRamp() throws Exception { | |||
if (colors == null) throw new Exception("Class num not set, color ramp null"); | |||
return colors; | |||
} | |||
|
|||
private void createRamp() { | |||
double step = (225.0 / (double) classNum); | |||
for (int i = 1; i <= classNum; i++) { | |||
colors.add(getColorForIndex(step, i)); | |||
} | |||
} | |||
|
|||
/** | |||
* Creates the color for the i-th class, using the provided color step | |||
* | |||
* @param step The color step | |||
* @param i The class counter | |||
* @return A color for this combination | |||
*/ | |||
protected abstract Color getColorForIndex(double step, int i); | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.