Skip to content

Commit

Permalink
Prepared fix for issue #1039.
Browse files Browse the repository at this point in the history
  • Loading branch information
nilsschmidt1337 committed Aug 7, 2024
1 parent 6198dc0 commit 88c0cf6
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/org/nschmidt/ldparteditor/text/PrimitiveReplacer.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,12 @@ public static List<String> substitutePrimitives(String shortFilename, int primit
shortFilename = shortFilename.substring(3);
}

return substitutePrimitivesParseFraction(key, shortFilename, primitiveSubstitutionQuality);
final List<String> value = substitutePrimitivesParseFraction(shortFilename, primitiveSubstitutionQuality);
// TODO GENERATED_PRIMITIVES_CACHE.put(key, value);
return value;
}

private static List<String> substitutePrimitivesParseFraction(PrimitiveKey key, String name, int quality) {
private static List<String> substitutePrimitivesParseFraction(String name, int quality) {
int length = name.length();

if (name.endsWith(".dat")) { //$NON-NLS-1$
Expand All @@ -70,9 +72,10 @@ private static List<String> substitutePrimitivesParseFraction(PrimitiveKey key,
boolean hasFraction = true;
int upper = 0;
int lower = 0;
int i;
for (i = 0; i < name.length(); i++) {
int i = 0;
while (i < length) {
if (!Character.isDigit(name.charAt(i))) break;
i++;
}

if (i > 0 && i < length && name.charAt(i) == '-') {
Expand Down Expand Up @@ -111,13 +114,13 @@ private static List<String> substitutePrimitivesParseFraction(PrimitiveKey key,

if (hasFraction) {
final PrimitiveFraction fraction = new PrimitiveFraction(upper, lower, hasFraction);
return substitutePrimitivesWithFraction(key, name, fraction, quality);
return substitutePrimitivesWithFraction(name, fraction, quality);
}

return substitutePrimitivesTori(key, name, quality);
return substitutePrimitivesTori(name, quality);
}

private static List<String> substitutePrimitivesWithFraction(PrimitiveKey key, String name, PrimitiveFraction fraction,
private static List<String> substitutePrimitivesWithFraction(String name, PrimitiveFraction fraction,
int quality) {
final int segments = quality * fraction.upper / fraction.lower;

Expand All @@ -135,7 +138,7 @@ private static List<String> substitutePrimitivesWithFraction(PrimitiveKey key, S
return List.of();
}

public static List<String> substituteRingPrimitivesWithFraction(String name, int quality, final int segments) {
private static List<String> substituteRingPrimitivesWithFraction(String name, int quality, final int segments) {
if (name.startsWith("ring") && name.length() > 4) { //$NON-NLS-1$
try {
final int size = Integer.parseInt(name.substring(4));
Expand Down Expand Up @@ -167,7 +170,7 @@ public static List<String> substituteRingPrimitivesWithFraction(String name, int
return List.of();
}

public static List<String> substituteSimplePrimitivesWithFraction(String name, int quality, final int segments) {
private static List<String> substituteSimplePrimitivesWithFraction(String name, int quality, final int segments) {
// Substitute edges
if ("edge".equals(name)) { //$NON-NLS-1$
return buildPrimitive(PrimGen2Dialog.CIRCLE, quality, segments);
Expand Down Expand Up @@ -201,7 +204,7 @@ public static List<String> substituteSimplePrimitivesWithFraction(String name, i
return List.of();
}

private static List<String> substitutePrimitivesTori(PrimitiveKey key, String name, int quality) {
private static List<String> substitutePrimitivesTori(String name, int quality) {

// TODO Needs implementation!

Expand Down

0 comments on commit 88c0cf6

Please sign in to comment.