mirror of
https://github.com/octoleo/plantuml.git
synced 2024-11-25 14:27:33 +00:00
refactor: prepare haxe version
This commit is contained in:
parent
8f074cfbdf
commit
9adc8dd067
@ -11,8 +11,9 @@ import java.util.Comparator;
|
||||
*/
|
||||
abstract public class CTSort
|
||||
{
|
||||
// ::remove folder when __HAXE__
|
||||
// ::remove folder when __CORE__
|
||||
// ::remove folder when __HAXE__
|
||||
// ::remove folder when __CORE__
|
||||
// ::remove folder when __MIT__
|
||||
public void sort(Object[] items)
|
||||
{
|
||||
sort(items, new DefaultComparator());
|
||||
|
@ -498,6 +498,22 @@ public class StringUtils {
|
||||
return s.toString().trim();
|
||||
}
|
||||
|
||||
public static String manageEscapedTabs(String s) {
|
||||
return s.replace("\\t", "\t");
|
||||
}
|
||||
|
||||
public static long seed(String string) {
|
||||
long h = 1125899906842597L; // prime
|
||||
final int len = string.length();
|
||||
|
||||
for (int i = 0; i < len; i++)
|
||||
h = 31 * h + string.charAt(i);
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
// ::done
|
||||
|
||||
public static String trin(String arg) {
|
||||
if (arg.length() == 0)
|
||||
return arg;
|
||||
@ -535,22 +551,6 @@ public class StringUtils {
|
||||
return c == ' ' || c == '\t' || c == '\r' || c == '\n' || c == '\0';
|
||||
}
|
||||
|
||||
public static String manageEscapedTabs(String s) {
|
||||
return s.replace("\\t", "\t");
|
||||
}
|
||||
|
||||
public static long seed(String string) {
|
||||
long h = 1125899906842597L; // prime
|
||||
final int len = string.length();
|
||||
|
||||
for (int i = 0; i < len; i++)
|
||||
h = 31 * h + string.charAt(i);
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
// ::done
|
||||
|
||||
public static String sharp000000(int color) {
|
||||
final int v = 0xFFFFFF & color;
|
||||
String s = "000000" + Integer.toHexString(v).toUpperCase();
|
||||
|
@ -38,21 +38,20 @@ import java.awt.Color;
|
||||
import java.util.Objects;
|
||||
|
||||
public class HColorGradient extends HColor {
|
||||
// ::remove file when __HAXE__
|
||||
|
||||
private final HColor color1;
|
||||
private final HColor color2;
|
||||
private final char policy;
|
||||
|
||||
HColorGradient(HColor color1, HColor color2, char policy) {
|
||||
if (color1 instanceof HColorGradient)
|
||||
color1 = ((HColorGradient) color1).color1;
|
||||
HColorGradient(HColor color1arg, HColor color2arg, char policy) {
|
||||
if (color1arg instanceof HColorGradient)
|
||||
color1arg = ((HColorGradient) color1arg).color1;
|
||||
|
||||
if (color2 instanceof HColorGradient)
|
||||
color2 = ((HColorGradient) color2).color2;
|
||||
if (color2arg instanceof HColorGradient)
|
||||
color2arg = ((HColorGradient) color2arg).color2;
|
||||
|
||||
this.color1 = Objects.requireNonNull(color1);
|
||||
this.color2 = Objects.requireNonNull(color2);
|
||||
this.color1 = Objects.requireNonNull(color1arg);
|
||||
this.color2 = Objects.requireNonNull(color2arg);
|
||||
this.policy = policy;
|
||||
}
|
||||
|
||||
@ -70,13 +69,18 @@ public class HColorGradient extends HColor {
|
||||
|
||||
final Color c1 = color1.toColor(mapper);
|
||||
final Color c2 = color2.toColor(mapper);
|
||||
final int vred = c2.getRed() - c1.getRed();
|
||||
final int vgreen = c2.getGreen() - c1.getGreen();
|
||||
final int vblue = c2.getBlue() - c1.getBlue();
|
||||
|
||||
final int diffRed = c2.getRed() - c1.getRed();
|
||||
final int diffGreen = c2.getGreen() - c1.getGreen();
|
||||
final int diffBlue = c2.getBlue() - c1.getBlue();
|
||||
|
||||
final int red = c1.getRed() + (int) (coeff * vred);
|
||||
final int green = c1.getGreen() + (int) (coeff * vgreen);
|
||||
final int blue = c1.getBlue() + (int) (coeff * vblue);
|
||||
final int vRed = (int) (coeff * diffRed);
|
||||
final int vGreen = (int) (coeff * diffGreen);
|
||||
final int vBlue = (int) (coeff * diffBlue);
|
||||
|
||||
final int red = c1.getRed() + vRed;
|
||||
final int green = c1.getGreen() + vGreen;
|
||||
final int blue = c1.getBlue() + vBlue;
|
||||
|
||||
return new Color(red, green, blue);
|
||||
|
||||
|
@ -161,11 +161,11 @@ public class HColors {
|
||||
public static HColor middle(HColor c1, HColor c2) {
|
||||
return new HColorMiddle(c1, c2);
|
||||
}
|
||||
// ::done
|
||||
|
||||
public static HColorGradient gradient(HColor color1, HColor color2, char policy) {
|
||||
return new HColorGradient(color1, color2, policy);
|
||||
}
|
||||
// ::done
|
||||
|
||||
public static HColor simple(Color c) {
|
||||
return HColorSimple.create(c);
|
||||
|
@ -159,9 +159,12 @@ public class FontConfiguration {
|
||||
&& fontPosition.equals(other.fontPosition) && tabSize == other.tabSize;
|
||||
}
|
||||
|
||||
public static FontConfiguration create(UFont font, HColor color, HColor hyperlinkColor,
|
||||
UStroke hyperlinkUnderlineStroke) {
|
||||
return create(font, color, hyperlinkColor, hyperlinkUnderlineStroke, 8);
|
||||
public FontConfiguration mute(Colors colors) {
|
||||
final HColor color = Objects.requireNonNull(colors).getColor(ColorType.TEXT);
|
||||
if (color == null)
|
||||
return this;
|
||||
|
||||
return changeColor(color);
|
||||
}
|
||||
|
||||
public static FontConfiguration create(ISkinParam skinParam, FontParam fontParam, Stereotype stereo) {
|
||||
@ -183,13 +186,20 @@ public class FontConfiguration {
|
||||
return create(style.getUFont(), color, hyperlinkColor, hyperlinkUnderlineStroke, skinParam.getTabSize());
|
||||
}
|
||||
|
||||
// ---
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return styles.toString() + " " + currentColor;
|
||||
}
|
||||
|
||||
// ::done
|
||||
|
||||
public static FontConfiguration create(UFont font, HColor color, HColor hyperlinkColor,
|
||||
UStroke hyperlinkUnderlineStroke) {
|
||||
return create(font, color, hyperlinkColor, hyperlinkUnderlineStroke, 8);
|
||||
}
|
||||
|
||||
// ---
|
||||
|
||||
public FontConfiguration forceFont(UFont newFont, HColor htmlColorForStereotype) {
|
||||
if (newFont == null)
|
||||
return add(FontStyle.ITALIC);
|
||||
@ -217,14 +227,6 @@ public class FontConfiguration {
|
||||
fontPosition, svgAttributes, hyperlinkColor, hyperlinkUnderlineStroke, tabSize);
|
||||
}
|
||||
|
||||
public FontConfiguration mute(Colors colors) {
|
||||
final HColor color = Objects.requireNonNull(colors).getColor(ColorType.TEXT);
|
||||
if (color == null)
|
||||
return this;
|
||||
|
||||
return changeColor(color);
|
||||
}
|
||||
|
||||
public FontConfiguration changeExtendedColor(HColor newExtendedColor) {
|
||||
return new FontConfiguration(styles, motherFont, motherColor, currentFont, currentColor, newExtendedColor,
|
||||
fontPosition, svgAttributes, hyperlinkColor, hyperlinkUnderlineStroke, tabSize);
|
||||
@ -337,6 +339,4 @@ public class FontConfiguration {
|
||||
// return new UStroke(3, 5, 2);
|
||||
}
|
||||
|
||||
// ::done
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user