mirror of
https://gitlab.com/oeffi/public-transport-enabler.git
synced 2025-07-14 16:40:30 +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.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
@ -370,6 +372,9 @@ public abstract class AbstractEfaProvider implements NetworkProvider
|
|||
if (type.equals("STR")) // Nordhausen
|
||||
return 'T' + str;
|
||||
|
||||
if (type.length() == 0)
|
||||
return "?";
|
||||
|
||||
throw new IllegalArgumentException("cannot normalize: " + number);
|
||||
}
|
||||
if (t == 1)
|
||||
|
@ -405,7 +410,10 @@ public abstract class AbstractEfaProvider implements NetworkProvider
|
|||
if (nameState.equals("identified"))
|
||||
{
|
||||
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());
|
||||
|
||||
|
@ -502,4 +510,23 @@ public abstract class AbstractEfaProvider implements NetworkProvider
|
|||
{
|
||||
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.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Andreas Schildbach
|
||||
|
@ -96,23 +94,4 @@ public class GvhProvider extends AbstractEfaProvider
|
|||
{
|
||||
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.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Andreas Schildbach
|
||||
|
@ -102,23 +100,4 @@ public class LinzProvider extends AbstractEfaProvider
|
|||
uri.append("&mode=direct");
|
||||
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
|
||||
{
|
||||
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("SS2", new int[] { Color.parseColor("#66cc00"), 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 });
|
||||
}
|
||||
|
||||
@Override
|
||||
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.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Andreas Schildbach
|
||||
|
@ -92,23 +90,4 @@ public class VrrProvider extends AbstractEfaProvider
|
|||
{
|
||||
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