mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-17 18:29:51 +00:00
extracted lineColors to common superclass
git-svn-id: https://public-transport-enabler.googlecode.com/svn/trunk@232 0924bc21-9374-b0fa-ee44-9ff1593b38f0
This commit is contained in:
parent
7cb981f289
commit
c5016a846b
5 changed files with 34 additions and 70 deletions
|
@ -22,7 +22,9 @@ import java.io.StringReader;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
@ -370,6 +372,9 @@ public abstract class AbstractEfaProvider implements NetworkProvider
|
||||||
if (type.equals("STR")) // Nordhausen
|
if (type.equals("STR")) // Nordhausen
|
||||||
return 'T' + str;
|
return 'T' + str;
|
||||||
|
|
||||||
|
if (type.length() == 0)
|
||||||
|
return "?";
|
||||||
|
|
||||||
throw new IllegalArgumentException("cannot normalize: " + number);
|
throw new IllegalArgumentException("cannot normalize: " + number);
|
||||||
}
|
}
|
||||||
if (t == 1)
|
if (t == 1)
|
||||||
|
@ -405,7 +410,10 @@ public abstract class AbstractEfaProvider implements NetworkProvider
|
||||||
if (nameState.equals("identified"))
|
if (nameState.equals("identified"))
|
||||||
{
|
{
|
||||||
XmlPullUtil.jumpToStartTag(pp, null, "odvNameElem");
|
XmlPullUtil.jumpToStartTag(pp, null, "odvNameElem");
|
||||||
final int locationId = Integer.parseInt(pp.getAttributeValue(null, "stopID"));
|
String locationIdStr = pp.getAttributeValue(null, "stopID");
|
||||||
|
if (locationIdStr == null)
|
||||||
|
locationIdStr = pp.getAttributeValue(null, "id");
|
||||||
|
final int locationId = Integer.parseInt(locationIdStr);
|
||||||
|
|
||||||
final String location = normalizeLocationName(pp.nextText());
|
final String location = normalizeLocationName(pp.nextText());
|
||||||
|
|
||||||
|
@ -502,4 +510,23 @@ public abstract class AbstractEfaProvider implements NetworkProvider
|
||||||
{
|
{
|
||||||
return (double) value / 1000000;
|
return (double) value / 1000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final Map<Character, int[]> LINES = new HashMap<Character, int[]>();
|
||||||
|
|
||||||
|
static
|
||||||
|
{
|
||||||
|
LINES.put('I', new int[] { Color.WHITE, Color.RED, Color.RED });
|
||||||
|
LINES.put('R', new int[] { Color.GRAY, Color.WHITE });
|
||||||
|
LINES.put('S', new int[] { Color.parseColor("#006e34"), Color.WHITE });
|
||||||
|
LINES.put('U', new int[] { Color.parseColor("#003090"), Color.WHITE });
|
||||||
|
LINES.put('T', new int[] { Color.parseColor("#cc0000"), Color.WHITE });
|
||||||
|
LINES.put('B', new int[] { Color.parseColor("#993399"), Color.WHITE });
|
||||||
|
LINES.put('F', new int[] { Color.BLUE, Color.WHITE });
|
||||||
|
LINES.put('?', new int[] { Color.DKGRAY, Color.WHITE });
|
||||||
|
}
|
||||||
|
|
||||||
|
public int[] lineColors(final String line)
|
||||||
|
{
|
||||||
|
return LINES.get(line.charAt(0));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,6 @@ package de.schildbach.pte;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andreas Schildbach
|
* @author Andreas Schildbach
|
||||||
|
@ -96,23 +94,4 @@ public class GvhProvider extends AbstractEfaProvider
|
||||||
{
|
{
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Map<Character, int[]> LINES = new HashMap<Character, int[]>();
|
|
||||||
|
|
||||||
static
|
|
||||||
{
|
|
||||||
LINES.put('I', new int[] { Color.WHITE, Color.RED, Color.RED });
|
|
||||||
LINES.put('R', new int[] { Color.GRAY, Color.WHITE });
|
|
||||||
LINES.put('S', new int[] { Color.parseColor("#006e34"), Color.WHITE });
|
|
||||||
LINES.put('U', new int[] { Color.parseColor("#003090"), Color.WHITE });
|
|
||||||
LINES.put('T', new int[] { Color.parseColor("#cc0000"), Color.WHITE });
|
|
||||||
LINES.put('B', new int[] { Color.parseColor("#993399"), Color.WHITE });
|
|
||||||
LINES.put('F', new int[] { Color.BLUE, Color.WHITE });
|
|
||||||
LINES.put('?', new int[] { Color.DKGRAY, Color.WHITE });
|
|
||||||
}
|
|
||||||
|
|
||||||
public int[] lineColors(final String line)
|
|
||||||
{
|
|
||||||
return LINES.get(line.charAt(0));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,6 @@ package de.schildbach.pte;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andreas Schildbach
|
* @author Andreas Schildbach
|
||||||
|
@ -102,23 +100,4 @@ public class LinzProvider extends AbstractEfaProvider
|
||||||
uri.append("&mode=direct");
|
uri.append("&mode=direct");
|
||||||
return uri.toString();
|
return uri.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Map<Character, int[]> LINES = new HashMap<Character, int[]>();
|
|
||||||
|
|
||||||
static
|
|
||||||
{
|
|
||||||
LINES.put('I', new int[] { Color.WHITE, Color.RED, Color.RED });
|
|
||||||
LINES.put('R', new int[] { Color.GRAY, Color.WHITE });
|
|
||||||
LINES.put('S', new int[] { Color.parseColor("#006e34"), Color.WHITE });
|
|
||||||
LINES.put('U', new int[] { Color.parseColor("#003090"), Color.WHITE });
|
|
||||||
LINES.put('T', new int[] { Color.parseColor("#cc0000"), Color.WHITE });
|
|
||||||
LINES.put('B', new int[] { Color.parseColor("#993399"), Color.WHITE });
|
|
||||||
LINES.put('F', new int[] { Color.BLUE, Color.WHITE });
|
|
||||||
LINES.put('?', new int[] { Color.DKGRAY, Color.WHITE });
|
|
||||||
}
|
|
||||||
|
|
||||||
public int[] lineColors(final String line)
|
|
||||||
{
|
|
||||||
return LINES.get(line.charAt(0));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -792,11 +792,6 @@ public class MvvProvider extends AbstractEfaProvider
|
||||||
|
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
LINES.put("I", new int[] { Color.WHITE, Color.RED, Color.RED }); // generic
|
|
||||||
LINES.put("R", new int[] { Color.WHITE, Color.RED, Color.RED }); // generic
|
|
||||||
LINES.put("S", new int[] { Color.parseColor("#006e34"), Color.WHITE }); // generic
|
|
||||||
LINES.put("U", new int[] { Color.parseColor("#003090"), Color.WHITE }); // generic
|
|
||||||
|
|
||||||
LINES.put("SS1", new int[] { Color.parseColor("#00ccff"), Color.WHITE });
|
LINES.put("SS1", new int[] { Color.parseColor("#00ccff"), Color.WHITE });
|
||||||
LINES.put("SS2", new int[] { Color.parseColor("#66cc00"), Color.WHITE });
|
LINES.put("SS2", new int[] { Color.parseColor("#66cc00"), Color.WHITE });
|
||||||
LINES.put("SS3", new int[] { Color.parseColor("#880099"), Color.WHITE });
|
LINES.put("SS3", new int[] { Color.parseColor("#880099"), Color.WHITE });
|
||||||
|
@ -833,8 +828,13 @@ public class MvvProvider extends AbstractEfaProvider
|
||||||
LINES.put("UU6", new int[] { Color.parseColor("#0000cc"), Color.WHITE });
|
LINES.put("UU6", new int[] { Color.parseColor("#0000cc"), Color.WHITE });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int[] lineColors(final String line)
|
public int[] lineColors(final String line)
|
||||||
{
|
{
|
||||||
return LINES.get(line);
|
final int[] lineColors = LINES.get(line);
|
||||||
|
if (lineColors != null)
|
||||||
|
return lineColors;
|
||||||
|
else
|
||||||
|
return super.lineColors(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,6 @@ package de.schildbach.pte;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andreas Schildbach
|
* @author Andreas Schildbach
|
||||||
|
@ -92,23 +90,4 @@ public class VrrProvider extends AbstractEfaProvider
|
||||||
{
|
{
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Map<Character, int[]> LINES = new HashMap<Character, int[]>();
|
|
||||||
|
|
||||||
static
|
|
||||||
{
|
|
||||||
LINES.put('I', new int[] { Color.WHITE, Color.RED, Color.RED });
|
|
||||||
LINES.put('R', new int[] { Color.GRAY, Color.WHITE });
|
|
||||||
LINES.put('S', new int[] { Color.parseColor("#006e34"), Color.WHITE });
|
|
||||||
LINES.put('U', new int[] { Color.parseColor("#003090"), Color.WHITE });
|
|
||||||
LINES.put('T', new int[] { Color.parseColor("#cc0000"), Color.WHITE });
|
|
||||||
LINES.put('B', new int[] { Color.parseColor("#993399"), Color.WHITE });
|
|
||||||
LINES.put('F', new int[] { Color.BLUE, Color.WHITE });
|
|
||||||
LINES.put('?', new int[] { Color.DKGRAY, Color.WHITE });
|
|
||||||
}
|
|
||||||
|
|
||||||
public int[] lineColors(final String line)
|
|
||||||
{
|
|
||||||
return LINES.get(line.charAt(0));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue