=====================================================================
Found a 102 line (495 tokens) duplication in the following files:
Starting at line 209 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameleader\animation2D\DistributedGisActorSingleImageRenderable.java
Starting at line 126 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameleader\animation2D\DistributedGisContentSingleImageRenderable.java
new BoundingBox(20, 20, 1.0));
}
}
//
// private methods
//
/**
* CustomPaint method.
*
* @param graphics the graphics
* @param extent the extent
* @param screen the screen
* @param observer the observer
* @param boundingBox the boundingbox to use
*/
private synchronized void customPaint(final Graphics2D graphics,
final Rectangle2D extent, final Dimension screen,
final ImageObserver observer, final BoundingBox boundingBox)
{
try
{
DirectedPoint location = this.source.getLocation();
Rectangle2D rectangle = BoundsUtil.getIntersect(this.source
.getLocation(), boundingBox, location.z);
if (!Shape.overlaps(extent, rectangle) && this.translate)
{
return;
}
Point2D screenCoordinates = Renderable2DInterface.Util
.getScreenCoordinates(this.source.getLocation().to2D(),
extent, screen);
// Let's transform
if (this.translate)
{
graphics.translate(screenCoordinates.getX(), screenCoordinates
.getY());
}
double scale = Renderable2DInterface.Util.getScale(extent, screen);
if (this.scale)
{
graphics.scale(1.0 / scale, 1.0 / scale);
}
double angle = -location.getRotZ();
if (this.flip && angle > Math.PI)
{
angle = angle - Math.PI;
}
if (this.rotate && angle != 0.0)
{
graphics.rotate(angle);
}
// Now we paint
this.customPaint(graphics, observer, boundingBox);
// Let's untransform
if (this.rotate && angle != 0.0)
{
graphics.rotate(-angle);
}
if (this.scale)
{
graphics.scale(scale, scale);
}
if (this.translate)
{
graphics.translate(-screenCoordinates.getX(),
-screenCoordinates.getY());
}
} catch (Exception exception)
{
Logger.warning(this, "paint", exception);
}
}
/**
* @param graphics the graphics
* @param observer the observer
* @param boundingBox the boundingbox
* @throws RemoteException thrown in case of a network error
*/
private void customPaint(final Graphics2D graphics,
final ImageObserver observer, final BoundingBox boundingBox)
throws RemoteException
{
int image = this.selectImage();
if (this.images[image].getImageLoadStatus() != MediaTracker.COMPLETE)
{
return;
}
Dimension size = BoundsUtil.getIntersect(this.source.getLocation(),
boundingBox, this.source.getLocation().z).getBounds().getSize();
Point2D origin = this.resolveOrigin(this.orientation, size);
graphics.translate(origin.getX(), origin.getY());
graphics.scale(0.001, 0.001);
graphics.drawImage(this.images[image].getImage(), 0, 0,
(int) (1000 * size.getWidth()),
(int) (1000 * size.getHeight()), observer);
graphics.scale(1000, 1000);
graphics.translate(-origin.getX(), -origin.getY());
}
}
=====================================================================
Found a 79 line (462 tokens) duplication in the following files:
Starting at line 126 of D:\java\gaming\supplychain-game\src\java\org\gscg\experiment\xsd\DistributorXSDParser.java
Starting at line 166 of D:\java\gaming\supplychain-game\src\java\org\gscg\experiment\xsd\ScriptXSDParser.java
String xsd = URLResource.getResource("/scenario.xsd")
.toExternalForm();
SAXBuilder builder = new SAXBuilder(
"org.apache.xerces.parsers.SAXParser", false);
// turns on Schema Validation with Xerces
builder.setFeature("http://xml.org/sax/features/validation", true);
Element rootElement = builder.build(xsd).getRootElement();
List list = rootElement.getChildren();
for (int i = 0; i < list.size(); i++)
{
Element child = (Element) list.get(i);
List attributes = child.getAttributes();
for (int attribute = 0; attribute < attributes.size(); attribute++)
{
Attribute element = (Attribute) attributes.get(attribute);
if (element.getValue().equalsIgnoreCase("productsEnum"))
{
for (int ii = 0; ii < child.getChildren().size(); ii++)
{
Element child2 = (Element) child.getChildren().get(
ii);
for (int iii = 0; iii < child2.getChildren().size(); iii++)
{
Element clone = (Element) ((Element) child2
.getChildren().get(iii)).clone();
child2.getChildren().clear();
for (int products = 0; products < Products
.getProductsArray().length; products++)
{
Element secondClone = (Element) clone
.clone();
Attribute attrib = secondClone
.getAttribute("value");
attrib.setValue((Products
.getProductsArray()[products])
.getName());
child2.addContent(secondClone);
}
break;
}
break;
}
}
if (element.getValue()
.equalsIgnoreCase("manufacturersEnum"))
{
for (int ii = 0; ii < child.getChildren().size(); ii++)
{
Element child2 = (Element) child.getChildren().get(
ii);
for (int iii = 0; iii < child2.getChildren().size(); iii++)
{
Element clone = (Element) ((Element) child2
.getChildren().get(iii)).clone();
child2.getChildren().clear();
for (int manufacturers = 0; manufacturers < Manufacturers
.getManufacturersArray().length; manufacturers++)
{
Element secondClone = (Element) clone
.clone();
Attribute attrib = secondClone
.getAttribute("value");
attrib
.setValue((Manufacturers
.getManufacturersArray()[manufacturers])
.getName());
child2.addContent(secondClone);
}
break;
}
break;
}
}
=====================================================================
Found a 105 line (457 tokens) duplication in the following files:
Starting at line 200 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\handlers\CommittedOrderHandler.java
Starting at line 202 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\handlers\ConfirmedOrderHandler.java
.getProposedDelivery().getDay());
Calendar startCalendar = Calendar.getInstance();
startCalendar.setTimeInMillis(GlobalRowOrColumnNumber
.getStartTime());
// calculcate difference between startCalendar and order date
int yearDiffence = calendar.get(Calendar.YEAR)
- startCalendar.get(Calendar.YEAR);
// reset old additional values
this.additionalDays = 0;
this.additionalWeeks = 0;
this.additionalMonths = 0;
while (yearDiffence > 0)
{
startCalendar.set(Calendar.YEAR, startCalendar
.get(Calendar.YEAR) + 1);
this.additionalDays = startCalendar
.getActualMaximum(Calendar.DAY_OF_YEAR);
this.additionalWeeks += 52;
this.additionalMonths += 12;
yearDiffence--;
}
// handle per day
this.handlePerDay(data, calendar);
// handle per week
this.handlePerWeek(data, calendar);
// handle per month
this.handlePerMonth(data, calendar);
return;
}
new ReceivedUnknownEventException(this, "notify", event.getType());
}
/**
* handles an orderconfirmation per day
*
* @param data the data
* @param calendar the calendar
*/
private void handlePerDay(final OrderConfirmationData data,
final Calendar calendar)
{
int day = calendar.get(Calendar.DAY_OF_YEAR);
// we compensate extra years
day += this.additionalDays;
if (this.currentDay != day)
{
this.currentDay = day;
}
double value = Double.NaN;
if (!this.productDayMap.containsKey(data.getProductName()))
{
Map map = new HashMap();
map.put("" + this.currentDay, new Double(data.getAmount()));
this.productDayMap.put(data.getProductName(), map);
value = data.getAmount();
} else
{
Map map = (Map) this.productDayMap.get(data.getProductName());
if (map.containsKey("" + this.currentDay))
{
value = ((Double) map.get("" + this.currentDay)).doubleValue();
value += data.getAmount();
map.put("" + this.currentDay, new Double(value));
} else
{
value = data.getAmount();
map.put("" + this.currentDay, new Double(value));
}
}
// lookup table row
try
{
int rowNumber = 0;
try
{
rowNumber = ((Integer) GlobalRowOrColumnNumber
.getDayNumberTableRowNumber().get(new Integer(day)))
.intValue();
} catch (NullPointerException nullPointerException)
{
if (this.dateWithinRange(data))
{
Logger.severe(this, "handlePerDay",
"Date should be in range, but no row found.");
} else
{
// set the scope outside the game
rowNumber = GlobalRowOrColumnNumber.getDayHeaderValues()
.size() + 10;
}
}
Event event = new Event(
=====================================================================
Found a 99 line (437 tokens) duplication in the following files:
Starting at line 466 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\handlers\CommittedOrderHandler.java
Starting at line 460 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\handlers\ConfirmedOrderHandler.java
ConfirmedOrderHandler.EVENT_NUMBER_ORDERCONFIRMED_RECEIVED_MONTH,
this, new CommittedOrderMonthData(data.getProductName(),
rowNumber, value));
this.fireEvent(event);
this.addToHistory("month", month, data.getProductName(), event);
} catch (Exception exception)
{
Logger.severe(this, "handlePerMonth", exception);
}
}
/**
* @see org.gscg.common.interactionlayer.AnnounceInterface#announce(nl.tudelft.simulation.event.EventType,
* boolean)
*/
public void announce(final EventType eventType, final boolean announce)
{
if (announce)
{
for (Iterator i = this.history.keySet().iterator(); i.hasNext();)
{
HashMap dateMap = (HashMap) this.history.get(i.next());
for (Iterator ii = dateMap.keySet().iterator(); ii.hasNext();)
{
HashMap productMap = (HashMap) dateMap.get(ii.next());
for (Iterator iii = productMap.keySet().iterator(); iii
.hasNext();)
{
try
{
this.owner
.notifyAnnounced((EventInterface) productMap
.get(iii.next()));
} catch (RemoteException remoteException)
{
Logger.severe(this, "announce", remoteException);
}
}
}
}
}
}
/**
* Method addToHistory.
*
* @param dateType a string reflecting the date type, e.g. day, week or
* month
* @param key the key, i.e. the number of the day, week or month
* @param productName the name of the product the confirmed order is
* received for
* @param event the event to store in the history
*/
private void addToHistory(final String dateType, final int key,
final String productName, final Event event)
{
HashMap dateMap = (HashMap) this.history.get(dateType);
if (dateMap == null)
{
dateMap = new HashMap();
this.history.put(dateType, dateMap);
}
HashMap productMap = (HashMap) dateMap.get(productName);
if (productMap == null)
{
productMap = new HashMap();
dateMap.put(productName, productMap);
}
productMap.put(new Integer(key), event);
}
/**
* calculates whether a date is within range
*
* @param data the data
* @return returns false if the date is not within range, true otherwise
*/
private boolean dateWithinRange(final OrderConfirmationData data)
{
Calendar startCalendar = Calendar.getInstance();
startCalendar.setTimeInMillis(GlobalRowOrColumnNumber.getStartTime());
Calendar endCalendar = Calendar.getInstance();
endCalendar.set(data.getProposedDelivery().getYear(), data
.getProposedDelivery().getMonth(), data.getProposedDelivery()
.getDay());
long runLength = GlobalRowOrColumnNumber.getNumberOfDays()
* TimeUnitInterface.DAY.getValue();
if ((endCalendar.getTimeInMillis() - startCalendar.getTimeInMillis()) > runLength)
{
return false;
}
return true;
}
}
=====================================================================
Found a 144 line (430 tokens) duplication in the following files:
Starting at line 223 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\interactionlayer\DistributorSingleUserInteractionLayer.java
Starting at line 227 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\interactionlayer\ManufacturerSingleUserInteractionLayer.java
Logger.severe(this, "ManufacturerSingleUserInteractionLayer",
exception);
}
}
/**
* @see org.gscg.singleuser.interactionlayer.SingleUserInteractionLayerInterface#addEventType(nl.tudelft.simulation.event.EventType)
*/
public void addEventType(final EventType eventType)
{
if (!this.eventTypes.contains(eventType))
{
this.eventTypes.add((eventType));
}
}
/**
* @see org.gscg.common.interactionlayer.GlobalInteractionLayerInterface#addEventTypeSentByClient(nl.tudelft.simulation.event.EventType)
*/
public void addEventTypeSentByClient(final EventType eventType)
{
if (!this.eventsSentByClient.contains(eventType))
{
this.eventsSentByClient.add((eventType));
}
}
/**
* @see org.gscg.common.interactionlayer.GlobalInteractionLayerInterface#addEventTypeToAnnounceList(nl.tudelft.simulation.event.EventType,
* org.gscg.common.interactionlayer.AnnounceInterface)
*/
public void addEventTypeToAnnounceList(final EventType eventType,
final AnnounceInterface announceObject)
{
String key = eventType.toString();
this.announceObjects.put(key, announceObject);
}
/**
* @see org.gscg.singleuser.interactionlayer.SingleUserInteractionLayerInterface#addStatisticEventType(nl.tudelft.simulation.event.EventType)
*/
public void addStatisticEventType(final EventType eventType)
{
if (!this.statisticEventTypes.contains(eventType))
{
this.statisticEventTypes.add(eventType);
}
}
/**
* @see org.gscg.common.interactionlayer.GlobalInteractionLayerInterface#getCache(java.lang.Object,
* nl.tudelft.simulation.event.EventType, boolean)
*/
public synchronized void getCache(final Object remoteEventProducer,
final EventType eventType, final boolean cache)
throws RemoteException
{
if (cache)
{
// only when there is no client logged in already we may update a
// client with cached information this code is meant to prevent
// initialization of a client user interface twice; which may occur
// if somebody uses a wrong user-name
if (!this.clientIsReady)
{
// client attempts to log on, start caching of events
this.shouldBeCaching = true;
synchronized (this.semaphore)
{
if (eventType
.equals(ScenarioText.CACHE_LARGE_NEWS_MESSAGE_EVENT))
{
ScenarioText.getScenarioText().announce(eventType,
true, this);
return;
}
if (this.announceObjects.containsKey(eventType.toString()))
{
AnnounceInterface object = (AnnounceInterface) this.announceObjects
.get(eventType.toString());
object.announce(eventType, true);
return;
}
if (eventType.equals(YellowPage.UPDATE_ACTORS))
{
// pass the locations
this.globalSupplyChainData.getYellowPage().update(true,
this);
// we need to add this event here, instead of in the
// location and name class
this.eventTypes.add(YellowPage.UPDATE_ACTORS);
this.eventTypes
.add(YellowPage.UPDATE_INTERACTIVE_PLAYER_STATUS);
return;
}
// update all the numbers for the messages in the game
if (eventType
.equals(GameActorContentStore.UPDATE_ALL_NUMBER_DATA_EVENT))
{
this.fireAllNumberData();
return;
}
// SPECIAL ANNOUNCE EVENTS USED DURING CLIENT INITIALIZATION
if (eventType
.equals(ClientInterface.INITIALIZATION_COMPLETED_EVENT))
{
if (this.simulator.isRunning())
{
this
.notifyAnnounced(new Event(
SimulatorInterface.START_EVENT,
this, null));
}
// as soon as the client disconnects, the remove
// listener method is invoked, as soon as the
// SimulatorInterface.TIME_CHANGED_EVENT event
// is received, the status is set to false
this.isReady(true);
try
{
// update the client with the cached events
// must be placed after this.isReady(boolean arg),
// otherwise a loop is created
while (this.cache.size() > 0)
{
this.notify((EventInterface) this.cache
.remove(0));
}
} catch (RemoteException remoteException)
{
// something went wrong during notification of the
// client; let's quit and log off the client
this.removeListener(null,
SimulatorInterface.TIME_CHANGED_EVENT);
}
this.shouldBeCaching = false;
Logger.info(this, "getCache",
=====================================================================
Found a 102 line (419 tokens) duplication in the following files:
Starting at line 429 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameactors\GameManufacturer.java
Starting at line 420 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameactors\GameDistributor.java
return new BoundingBox(1.0, 1.0, 0.0);
}
/**
* Method getContent returns all data objects of type contentClass
*
* @param contentClass the content class to look for
* @param sent indicates whether the content is sent or received
* @param productName the name of the product
*/
public void fireAllContentData(final Class contentClass,
final boolean sent, final String productName)
{
getGameContentStore().fireAllProductContentData(contentClass, sent,
productName);
}
/**
* Method fireAllNumberData.
*/
public void fireAllNumberData()
{
Collection products = this.globalSupplyChainData.getProducts();
Iterator prodIter = products.iterator();
while (prodIter.hasNext())
{
Product product = (Product) prodIter.next();
getGameContentStore().fireAllProductNumberData(product.getName());
}
}
/**
* @param productName the product we want
* @return an initialized RFQData object with potential suppliers
*/
public RFQDataSuppliers getInitialRFQData(final String productName)
{
double day = 0;
try
{
day = TimeUnit.convert(1, TimeUnitInterface.DAY, this.simulator);
} catch (Exception exception)
{
Logger.severe(this, "getInitialRFQData", "TimeUnit.convert failed");
}
// TODO the desired earliest and delivery date should not be hard-coded
double earliestDeliveryDate = this.getSimulatorTime() + 14 * day;
double defaultAmount = 100;
double latestDeliveryDate = earliestDeliveryDate + 7.0 * day;
String[] supplierNames = new String[0];
String[] supplierNickNames = new String[0];
Point2d ownLocation = new Point2d(this.getLocation().x, this
.getLocation().y);
Point2d[] suppliersLocations = new Point2d[0];
Set suppliers = (Set) this.productNameToSuppliers.get(productName);
if (suppliers != null)
{
supplierNames = new String[suppliers.size()];
supplierNickNames = new String[suppliers.size()];
suppliersLocations = new Point2d[suppliers.size()];
int counter = 0;
for (Iterator it = suppliers.iterator(); it.hasNext();)
{
Trader trader = (Trader) it.next();
supplierNames[counter] = trader.getName();
supplierNickNames[counter] = trader.getLocationDescription();
suppliersLocations[counter] = new Point2d(
trader.getLocation().x, trader.getLocation().y);
counter++;
}
}
return new RFQDataSuppliers(this.name, supplierNames,
supplierNickNames, DateIntData.makeDateIntData(
earliestDeliveryDate, this.simulator), DateIntData
.makeDateIntData(latestDeliveryDate, this.simulator),
defaultAmount, productName, ownLocation, suppliersLocations);
}
/**
* @return Returns the smallMapLocation.
*/
public DirectedPoint getSmallMapLocation()
{
return this.smallMapLocation;
}
/**
* @param smallMapLocation The smallMapLocation to set.
*/
public void setSmallMapLocation(final DirectedPoint smallMapLocation)
{
this.smallMapLocation = smallMapLocation;
}
/**
* @see org.gscg.gameactors.GameInteractiveActorRoleInterface#getGameContentStore()
*/
public GameActorContentStore getGameContentStore()
=====================================================================
Found a 65 line (364 tokens) duplication in the following files:
Starting at line 102 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameleader\dialogs\content\components\OrderBasedOnQuoteContentPanel.java
Starting at line 106 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameleader\dialogs\content\components\QuoteContentPanel.java
.getOrder()).getQuote();
}
if (this.content != null)
{
this.initialize();
} else
{
Logger.severe(this, "<init>",
"Could not extract content from received content of class: "
+ content.getClass());
}
}
/**
* @see org.gscg.gameleader.dialogs.components.AbstractPanel#initialize()
*/
protected void initialize()
{
JPanel labelPanel = new JPanel();
// col1, row1, col2, row2, hAlign, vAlign
double[][] nameLabelPanelLayout = {
{TableLayoutConstants.FILL, TableLayoutConstants.FILL},
{20, 20, 20, 20, 20, 20}};
labelPanel.setLayout(new TableLayout(nameLabelPanelLayout));
labelPanel.setBackground(Color.WHITE);
JLabel senderLabel = super.getFormattedLabel("sender name");
labelPanel.add(senderLabel, "0,0,L,C");
JLabel senderNameLabel = super.getFormattedLabel(this.content
.getSender().getName());
senderNameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
labelPanel.add(senderNameLabel, "1,0,R,C");
JLabel receiverLabel = super.getFormattedLabel("receiver name");
labelPanel.add(receiverLabel, "0,1,L,C");
JLabel receiverNameLabel = super.getFormattedLabel(this.content
.getReceiver().getName());
receiverNameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
labelPanel.add(receiverNameLabel, "1,1,R,C");
JLabel productLabel = super.getFormattedLabel("product name");
labelPanel.add(productLabel, "0,2,L,C");
JLabel productNameLabel = super.getFormattedLabel(this.content
.getProduct().getName());
productNameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
labelPanel.add(productNameLabel, "1,2,R,C");
JLabel amountLabel = super.getFormattedLabel("amount");
labelPanel.add(amountLabel, "0,3,L,C");
JLabel amountNameLabel = super.getFormattedLabel(this.content
.getAmount()
+ "");
amountNameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
labelPanel.add(amountNameLabel, "1,3,R,C");
JLabel priceLabel = super.getFormattedLabel("price");
labelPanel.add(priceLabel, "0,4,L,C");
JLabel priceNameLabel = super.getFormattedLabel(this.content.getPrice()
+ "");
priceNameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
labelPanel.add(priceNameLabel, "1,4,R,C");
JLabel earliestDeliveryLabel = super
.getFormattedLabel("proposed delivery");
=====================================================================
Found a 75 line (360 tokens) duplication in the following files:
Starting at line 306 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\handlers\CommittedOrderHandler.java
Starting at line 307 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\handlers\ConfirmedOrderHandler.java
ConfirmedOrderHandler.EVENT_NUMBER_ORDERCONFIRMED_RECEIVED_DAY,
this, new CommittedOrderDayData(data.getProductName(),
rowNumber, value));
this.fireEvent(event);
this.addToHistory("day", day, data.getProductName(), event);
} catch (Exception exception)
{
Logger.severe(this, "handlePerDay", exception);
}
}
/**
* handles an orderconfirmation per week
*
* @param data the data
* @param calendar the calendar
*/
private void handlePerWeek(final OrderConfirmationData data,
final Calendar calendar)
{
int week = (calendar.get(Calendar.WEEK_OF_YEAR));
// we compensate extra years
week += this.additionalWeeks;
if (this.currentWeek != week)
{
this.currentWeek = week;
}
double value = Double.NaN;
if (!this.productWeekMap.containsKey(data.getProductName()))
{
Map map = new HashMap();
map.put("" + this.currentWeek, new Double(data.getAmount()));
this.productWeekMap.put(data.getProductName(), map);
value = data.getAmount();
} else
{
Map map = (Map) this.productWeekMap.get(data.getProductName());
if (map.containsKey("" + this.currentWeek))
{
value = ((Double) map.get("" + this.currentWeek)).doubleValue();
value += data.getAmount();
map.put("" + this.currentWeek, new Double(value));
} else
{
value = data.getAmount();
map.put("" + this.currentWeek, new Double(value));
}
}
// lookup table row
try
{
int rowNumber = 0;
try
{
rowNumber = ((Integer) GlobalRowOrColumnNumber
.getWeekNumberTableRowNumber().get(new Integer(week)))
.intValue();
} catch (NullPointerException nullPointerException)
{
if (this.dateWithinRange(data))
{
Logger.severe(this, "handlePerWeek",
"Date should be in range, but no row found.");
} else
{
// set the scope outside the game
rowNumber = GlobalRowOrColumnNumber.getWeekHeaderValues()
.size() + 10;
}
}
=====================================================================
Found a 133 line (349 tokens) duplication in the following files:
Starting at line 655 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameactors\GameDistributorInteractive.java
Starting at line 656 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameactors\GameManufacturerInteractive.java
+ this.name
+ " set to interactive mode since the warm-up period has been finished");
this.addInteractiveContentHandlers();
return;
}
new ReceivedUnknownEventException(this, "notify", event.getType());
}
/**
* pays the bill
*
* @param bill the bill to pay
*/
public void pay(final Bill bill)
{
this.bankAccount.withdrawFromBalance(bill.getPrice());
}
/**
* @see nl.tudelft.simulation.content.HandlerInterface#handleContent(java.io.Serializable)
*/
public boolean handleContent(final Serializable content)
{
try
{
if (super.humanControlled)
{
if (content instanceof Quote)
{
// handle with the special interactive quote handler
if (super.interactiveQuoteHandler.handleContent(content))
{
// save content in the content store
super.getContentStore().addContent((Content) content,
false);
}
return true;
}
}
return super.handleContent(content);
} catch (Exception exception)
{
Logger.severe(this, "handleContent", exception);
return false;
}
}
/**
* @see nl.tudelft.simulation.supplychain.actor.SupplyChainActor#sendContent(nl.tudelft.simulation.supplychain.content.Content,
* double)
*/
public void sendContent(final Content content,
final double administrativeDelay)
{
super.sendContent(content, administrativeDelay);
}
/**
* @see org.gscg.gameactors.GameActorInteractiveInterface#getSingleUserInteractionLayer()
*/
public SingleUserInteractionLayerInterface getSingleUserInteractionLayer()
{
return this.singleUserInteractionLayer;
}
/**
* @see org.gscg.gameactors.GameActorInteractiveInterface#setSingleUserInteractionLayer(org.gscg.singleuser.interactionlayer.SingleUserInteractionLayerInterface)
*/
public void setSingleUserInteractionLayer(
final SingleUserInteractionLayerInterface singleUserInteractionLayer)
{
this.singleUserInteractionLayer = singleUserInteractionLayer;
getGameContentStore().setSingleUserInteractionlayer(
this.singleUserInteractionLayer);
try
{
for (int i = 0; i < this.eventsSentByClientArray.length; i++)
{
this.singleUserInteractionLayer.addListener(this,
this.eventsSentByClientArray[i], false);
this.singleUserInteractionLayer
.addEventTypeSentByClient(this.eventsSentByClientArray[i]);
}
// announce to update the stock
// add the announce events
singleUserInteractionLayer.addEventTypeToAnnounceList(
StockInterface.STOCK_CHANGE_EVENT, this);
//
// listeners
//
// subscribe for time change events on a daily basis these
// events are used to update client side statistics on a daily basis
this.singleUserInteractionLayer.addListener(this,
GlobalRowOrColumnNumber.UPDATE_CURRENT_DAY);
} catch (RemoteException remoteException)
{
Logger.severe(this, "<init>", remoteException);
}
//
// CUSTOMER STATISTICS
//
this.customerStatistics = new CustomerStatistics(this.simulator,
this.singleUserInteractionLayer);
}
/**
* adds computer-controlled interactive content handlers
*/
public void addComputerControlledContentHandlers()
{
super.addComputerControlledContentHandlers();
}
/**
* adds interactive content handlers
*/
public void addInteractiveContentHandlers()
{
// remove all previus content handlers
this.removeAllContentHandlers();
// look for our personal xml file with handler description
URL url = URLResource.getResource("/" + this.name + "_interactive.xml");
if (url == null)
{
url = URLResource
.getResource("/manufacturer_interactive_default_handler.xml");
=====================================================================
Found a 72 line (325 tokens) duplication in the following files:
Starting at line 394 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\handlers\CommittedOrderHandler.java
Starting at line 388 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\handlers\ConfirmedOrderHandler.java
} catch (Exception exception)
{
Logger.severe(this, "handlePerWeek", exception);
}
}
/**
* handles an orderconfirmation per month
*
* @param data the data
* @param calendar the calendar
*/
private void handlePerMonth(final OrderConfirmationData data,
final Calendar calendar)
{
int month = calendar.get(Calendar.MONTH);
// we compensate extra years
month += this.additionalMonths;
if (this.currentMonth != month)
{
this.currentMonth = month;
}
double value = Double.NaN;
if (!this.productMonthMap.containsKey(data.getProductName()))
{
Map map = new HashMap();
map.put("" + this.currentMonth, new Double(data.getAmount()));
this.productMonthMap.put(data.getProductName(), map);
value = data.getAmount();
} else
{
Map map = (Map) this.productMonthMap.get(data.getProductName());
if (map.containsKey("" + this.currentMonth))
{
value = ((Double) map.get("" + this.currentMonth))
.doubleValue();
value += data.getAmount();
map.put("" + this.currentMonth, new Double(value));
} else
{
value = data.getAmount();
map.put("" + this.currentMonth, new Double(value));
}
}
// lookup table row
try
{
int rowNumber = 0;
try
{
rowNumber = ((Integer) GlobalRowOrColumnNumber
.getMonthNumberTableRowNumber().get(new Integer(month)))
.intValue();
} catch (NullPointerException nullPointerException)
{
if (this.dateWithinRange(data))
{
Logger.severe(this, "handlePerMonth",
"Date should be in range, but no row found.");
} else
{
// set the scope outside the game
rowNumber = GlobalRowOrColumnNumber.getMonthHeaderValues()
.size() + 10;
}
}
Event event = new Event(
=====================================================================
Found a 57 line (308 tokens) duplication in the following files:
Starting at line 102 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameleader\dialogs\content\components\OrderBasedOnQuoteContentPanel.java
Starting at line 113 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameleader\dialogs\content\components\RequestForQuoteContentPanel.java
.getOrder()).getQuote().getRequestForQuote();
}
if (this.content != null)
{
this.initialize();
} else
{
Logger.severe(this, "<init>",
"Could not extract content from received content of class: "
+ content.getClass());
}
}
/**
* @see org.gscg.gameleader.dialogs.components.AbstractPanel#initialize()
*/
protected void initialize()
{
JPanel labelPanel = new JPanel();
// col1, row1, col2, row2, hAlign, vAlign
double[][] nameLabelPanelLayout = {
{TableLayoutConstants.FILL, TableLayoutConstants.FILL},
{20, 20, 20, 20, 20, 20}};
labelPanel.setLayout(new TableLayout(nameLabelPanelLayout));
labelPanel.setBackground(Color.WHITE);
JLabel senderLabel = super.getFormattedLabel("sender name");
labelPanel.add(senderLabel, "0,0,L,C");
JLabel senderNameLabel = super.getFormattedLabel(this.content
.getSender().getName());
senderNameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
labelPanel.add(senderNameLabel, "1,0,R,C");
JLabel receiverLabel = super.getFormattedLabel("receiver name");
labelPanel.add(receiverLabel, "0,1,L,C");
JLabel receiverNameLabel = super.getFormattedLabel(this.content
.getReceiver().getName());
receiverNameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
labelPanel.add(receiverNameLabel, "1,1,R,C");
JLabel productLabel = super.getFormattedLabel("product name");
labelPanel.add(productLabel, "0,2,L,C");
JLabel productNameLabel = super.getFormattedLabel(this.content
.getProduct().getName());
productNameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
labelPanel.add(productNameLabel, "1,2,R,C");
JLabel amountLabel = super.getFormattedLabel("amount");
labelPanel.add(amountLabel, "0,3,L,C");
JLabel amountNameLabel = super.getFormattedLabel(this.content
.getAmount()
+ "");
amountNameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
labelPanel.add(amountNameLabel, "1,3,R,C");
JLabel earliestDeliveryLabel = super
=====================================================================
Found a 76 line (297 tokens) duplication in the following files:
Starting at line 470 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\handlers\CommittedOrderHandler.java
Starting at line 543 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\handlers\ConfirmedProductionHandler.java
.getName(), event);
} catch (Exception exception)
{
Logger.severe(this, "handlePerMonth", exception);
}
}
/**
* @see org.gscg.common.interactionlayer.AnnounceInterface#announce(nl.tudelft.simulation.event.EventType,
* boolean)
*/
public void announce(final EventType eventType, final boolean announce)
{
if (announce)
{
for (Iterator i = this.history.keySet().iterator(); i.hasNext();)
{
HashMap dateMap = (HashMap) this.history.get(i.next());
for (Iterator ii = dateMap.keySet().iterator(); ii.hasNext();)
{
HashMap productMap = (HashMap) dateMap.get(ii.next());
for (Iterator iii = productMap.keySet().iterator(); iii
.hasNext();)
{
try
{
this.owner
.notifyAnnounced((EventInterface) productMap
.get(iii.next()));
} catch (RemoteException remoteException)
{
Logger.severe(this, "announce", remoteException);
}
}
}
}
}
}
/**
* Method addToHistory.
*
* @param dateType a string reflecting the date type, e.g. day, week or
* month
* @param key the key, i.e. the number of the day, week or month
* @param productName the name of the product the confirmed order is
* received for
* @param event the event to store in the history
*/
private void addToHistory(final String dateType, final int key,
final String productName, final Event event)
{
HashMap dateMap = (HashMap) this.history.get(dateType);
if (dateMap == null)
{
dateMap = new HashMap();
this.history.put(dateType, dateMap);
}
HashMap productMap = (HashMap) dateMap.get(productName);
if (productMap == null)
{
productMap = new HashMap();
dateMap.put(productName, productMap);
}
productMap.put(new Integer(key), event);
}
/**
* calculates whether a date is within range
*
* @param data the data
* @return returns false if the date is not within range, true otherwise
*/
private boolean dateWithinRange(final ProductionStartedData data)
=====================================================================
Found a 41 line (296 tokens) duplication in the following files:
Starting at line 96 of D:\java\gaming\supplychain-game\src\java\org\gscg\common\gui\statistics\components\StatisticsStockXYChart.java
Starting at line 143 of D:\java\gaming\supplychain-game\src\java\org\gscg\common\gui\statistics\components\StatisticsStockXYChart.java
{
for (int i = 0; i < this.series.size(); i++)
{
if (((XYSeries) this.series.get(i)).getSeriesName()
.indexOf(productName) >= 0)
{
if (((XYSeries) this.series.get(i)).getSeriesName()
.indexOf("actual") >= 0)
{
((XYSeries) this.series.get(i))
.notify(new TimedEvent(event.getType(),
event.getSource(),
new Double(data
.getActualAmount()),
((TimedEvent) event)
.getTimeStamp()));
}
if (((XYSeries) this.series.get(i)).getSeriesName()
.indexOf("committed") >= 0)
{
((XYSeries) this.series.get(i))
.notify(new TimedEvent(event.getType(),
event.getSource(),
new Double(data
.getClaimedAmount()),
((TimedEvent) event)
.getTimeStamp()));
}
if (((XYSeries) this.series.get(i)).getSeriesName()
.indexOf("ordered") >= 0)
{
((XYSeries) this.series.get(i))
.notify(new TimedEvent(event.getType(),
event.getSource(),
new Double(data
.getOrderedAmount()),
((TimedEvent) event)
.getTimeStamp()));
}
}
}
=====================================================================
Found a 49 line (296 tokens) duplication in the following files:
Starting at line 126 of D:\java\gaming\supplychain-game\src\java\org\gscg\experiment\xsd\DistributorXSDParser.java
Starting at line 125 of D:\java\gaming\supplychain-game\src\java\org\gscg\experiment\xsd\MarketXSDParser.java
String xsd = URLResource.getResource("/market.xsd")
.toExternalForm();
SAXBuilder builder = new SAXBuilder(
"org.apache.xerces.parsers.SAXParser", false);
// turns on Schema Validation with Xerces
builder.setFeature("http://xml.org/sax/features/validation", true);
Element rootElement = builder.build(xsd).getRootElement();
List list = rootElement.getChildren();
for (int i = 0; i < list.size(); i++)
{
Element child = (Element) list.get(i);
List attributes = child.getAttributes();
for (int attribute = 0; attribute < attributes.size(); attribute++)
{
Attribute element = (Attribute) attributes.get(attribute);
if (element.getValue().equalsIgnoreCase("productsEnum"))
{
for (int ii = 0; ii < child.getChildren().size(); ii++)
{
Element child2 = (Element) child.getChildren().get(
ii);
for (int iii = 0; iii < child2.getChildren().size(); iii++)
{
Element clone = (Element) ((Element) child2
.getChildren().get(iii)).clone();
child2.getChildren().clear();
for (int products = 0; products < Products
.getProductsArray().length; products++)
{
Element secondClone = (Element) clone
.clone();
Attribute attrib = secondClone
.getAttribute("value");
attrib.setValue((Products
.getProductsArray()[products])
.getName());
child2.addContent(secondClone);
}
break;
}
break;
}
}
if (element.getValue().equalsIgnoreCase("distributorsEnum"))
=====================================================================
Found a 55 line (286 tokens) duplication in the following files:
Starting at line 502 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameactors\GameDistributorInteractive.java
Starting at line 503 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameactors\GameManufacturerInteractive.java
GameManufacturerInteractive.QUOTE_SENT_BY_CLIENT_EVENT))
{
SentQuoteData data = (SentQuoteData) event.getContent();
try
{
SupplyChainActor sender = this.globalSupplyChainData
.getSupplyChainActor(data.getSenderName());
SupplyChainActor receiver = this.globalSupplyChainData
.getSupplyChainActor(data.getReceiverName());
// find the rfq
List rfqs = super.getGameContentStore().getContentList(
data.getRfqData().getInternalDemandIdentifier(),
RequestForQuote.class, false);
RequestForQuote rfq = null;
for (int i = 0; i < rfqs.size(); i++)
{
RequestForQuote result = (RequestForQuote) rfqs.get(i);
if (result.getReceiver().getName().equalsIgnoreCase(
sender.getName()))
{
rfq = result;
break;
}
}
double proposedDeliveryDate = DateIntData.makeSimulationDate(
data.getProposedDelivery(), this.simulator);
if (proposedDeliveryDate > this.simulator.getSimulatorTime())
{
double price = data.getPrice();
// we add the transportation costs
double weight = rfq.getAmount()
* rfq.getProduct().getAverageUnitWeight();
// calculate the costs based on the the lat lon distance!
double transportCosts = TransportMode.PLANE.transportCosts(
super.latLonDistanceCalculator.getDistance(rfq
.getSender(), rfq.getReceiver()), weight);
// add the transport costs to the price
price += transportCosts;
Quote quote = new Quote(sender, receiver, data.getRfqData()
.getInternalDemandIdentifier(), rfq, rfq
.getProduct(), data.getAmount(), price,
proposedDeliveryDate, TransportMode.PLANE);
this.sendContent(quote, 0.0);
} else
{
Logger
.info(
this,
"notify",
=====================================================================
Found a 48 line (286 tokens) duplication in the following files:
Starting at line 126 of D:\java\gaming\supplychain-game\src\java\org\gscg\experiment\xsd\DistributorXSDParser.java
Starting at line 85 of D:\java\gaming\supplychain-game\src\java\org\gscg\experiment\xsd\ManufacturerXSDParser.java
String xsd = URLResource.getResource("/manufacturer.xsd")
.toExternalForm();
SAXBuilder builder = new SAXBuilder(
"org.apache.xerces.parsers.SAXParser", false);
// turns on Schema Validation with Xerces
builder.setFeature("http://xml.org/sax/features/validation", true);
Element rootElement = builder.build(xsd).getRootElement();
List list = rootElement.getChildren();
for (int i = 0; i < list.size(); i++)
{
Element child = (Element) list.get(i);
List attributes = child.getAttributes();
for (int attribute = 0; attribute < attributes.size(); attribute++)
{
Attribute element = (Attribute) attributes.get(attribute);
if (element.getValue().equalsIgnoreCase("productsEnum"))
{
for (int ii = 0; ii < child.getChildren().size(); ii++)
{
Element child2 = (Element) child.getChildren().get(
ii);
for (int iii = 0; iii < child2.getChildren().size(); iii++)
{
Element clone = (Element) ((Element) child2
.getChildren().get(iii)).clone();
child2.getChildren().clear();
for (int products = 0; products < Products
.getProductsArray().length; products++)
{
Element secondClone = (Element) clone
.clone();
Attribute attrib = secondClone
.getAttribute("value");
attrib.setValue((Products
.getProductsArray()[products])
.getName());
child2.addContent(secondClone);
}
break;
}
break;
}
}
=====================================================================
Found a 62 line (270 tokens) duplication in the following files:
Starting at line 218 of D:\java\gaming\supplychain-game\src\java\org\gscg\experiment\DistributorParser.java
Starting at line 220 of D:\java\gaming\supplychain-game\src\java\org\gscg\experiment\ManufacturerParser.java
}
/**
* Parses an element representing a list of products
*
* @param element the element to parse
* @return returns an array with products
* @throws Exception thrown in case of an unknown name
*/
private static Product[] parseProduct(final Element element)
throws Exception
{
List products = element.getChildren();
List result = new ArrayList();
for (int i = 0; i < products.size(); i++)
{
Element product = (Element) products.get(i);
Namespace space = element.getNamespace();
String name = null;
if (product.getChild("product", space) != null)
{
name = (product.getChildText("product", space));
}
result.add(Products.getProduct(name));
}
return (Product[]) result.toArray(new Product[result.size()]);
}
/**
* Parses an element representing a list of products
*
* @param element the element to parse
* @return returns an array with products
* @throws Exception thrown in case of an unknown name
*/
private static Double[] parseAmount(final Element element) throws Exception
{
List products = element.getChildren();
List result = new ArrayList();
for (int i = 0; i < products.size(); i++)
{
Element product = (Element) products.get(i);
Namespace space = element.getNamespace();
double amount = Double.NaN;
if (product.getChild("initial_amount", space) != null)
{
amount = new Double(product.getChildText("initial_amount",
space)).doubleValue();
}
result.add(new Double(amount));
}
return (Double[]) result.toArray(new Double[result.size()]);
}
/**
* Parses a element representing a list of suppliers
*
* @param element the element to parse
* @return returns an array with suppliers
* @throws Exception thrown in case of an unknown name
*/
private static GameSupplier[] parseSupplier(final Element element)
=====================================================================
Found a 53 line (268 tokens) duplication in the following files:
Starting at line 218 of D:\java\gaming\supplychain-game\src\java\org\gscg\experiment\DistributorParser.java
Starting at line 193 of D:\java\gaming\supplychain-game\src\java\org\gscg\experiment\SupplierParser.java
}
/**
* Parses an element representing a list of products
*
* @param element the element to parse
* @return returns an array with products
* @throws Exception thrown in case of an unknown name
*/
private static Product[] parseProduct(final Element element)
throws Exception
{
List products = element.getChildren();
List result = new ArrayList();
for (int i = 0; i < products.size(); i++)
{
Element product = (Element) products.get(i);
Namespace space = element.getNamespace();
String name = null;
if (product.getChild("product", space) != null)
{
name = (product.getChildText("product", space));
}
result.add(Products.getProduct(name));
}
return (Product[]) result.toArray(new Product[result.size()]);
}
/**
* Parses an element representing a list of products
*
* @param element the element to parse
* @return returns an array with products
* @throws Exception thrown in case of an unknown name
*/
private static Double[] parseAmount(final Element element) throws Exception
{
List products = element.getChildren();
List result = new ArrayList();
for (int i = 0; i < products.size(); i++)
{
Element product = (Element) products.get(i);
Namespace space = element.getNamespace();
double amount = Double.NaN;
if (product.getChild("initial_amount", space) != null)
{
amount = new Double(product.getChildText("initial_amount",
space)).doubleValue();
}
result.add(new Double(amount));
}
return (Double[]) result.toArray(new Double[result.size()]);
}
=====================================================================
Found a 48 line (264 tokens) duplication in the following files:
Starting at line 76 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameleader\dialogs\content\components\OrderConfirmationContentPanel.java
Starting at line 75 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameleader\dialogs\content\components\ShipmentContentPanel.java
this.content = (Shipment) content;
}
if (this.content != null)
{
this.initialize();
} else
{
Logger.severe(this, "<init>",
"Could not extract content from received content of class: "
+ content.getClass());
}
}
/**
* @see org.gscg.gameleader.dialogs.components.AbstractPanel#initialize()
*/
protected void initialize()
{
JPanel labelPanel = new JPanel();
// col1, row1, col2, row2, hAlign, vAlign
double[][] nameLabelPanelLayout = {
{TableLayoutConstants.FILL, TableLayoutConstants.FILL},
{20, 20, 20, 20, 20, 20}};
labelPanel.setLayout(new TableLayout(nameLabelPanelLayout));
labelPanel.setBackground(Color.WHITE);
JLabel senderLabel = super.getFormattedLabel("sender name");
labelPanel.add(senderLabel, "0,0,L,C");
JLabel senderNameLabel = super.getFormattedLabel(this.content
.getSender().getName());
senderNameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
labelPanel.add(senderNameLabel, "1,0,R,C");
JLabel receiverLabel = super.getFormattedLabel("receiver name");
labelPanel.add(receiverLabel, "0,1,L,C");
JLabel receiverNameLabel = super.getFormattedLabel(this.content
.getReceiver().getName());
receiverNameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
labelPanel.add(receiverNameLabel, "1,1,R,C");
JLabel productLabel = super.getFormattedLabel("product name");
labelPanel.add(productLabel, "0,2,L,C");
JLabel productNameLabel = super.getFormattedLabel(this.content
.getProduct().getName());
productNameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
labelPanel.add(productNameLabel, "1,2,R,C");
JLabel statusLabel = super.getFormattedLabel("amount");
=====================================================================
Found a 54 line (262 tokens) duplication in the following files:
Starting at line 426 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameactors\GameDistributorInteractive.java
Starting at line 427 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameactors\GameManufacturerInteractive.java
GameManufacturerInteractive.SELECTED_QUOTE_EVENT))
{
QuoteData data = (QuoteData) event.getContent();
// first create the quote
SupplyChainActor sender = this.globalSupplyChainData
.getSupplyChainActor(data.getSenderName());
try
{
double proposedDeliveryDate = DateIntData.makeSimulationDate(
data.getProposedDelivery(), this.simulator);
List quotes = super.getGameContentStore().getContentList(
data.getRfqData().getInternalDemandIdentifier(),
Quote.class, false);
OrderBasedOnQuote order = null;
for (int i = 0; i < quotes.size(); i++)
{
Quote quote = (Quote) quotes.get(i);
if (quote.getSender().getName().equalsIgnoreCase(
sender.getName()))
{
order = new OrderBasedOnQuote(quote.getReceiver(),
quote.getSender(), data.getRfqData()
.getInternalDemandIdentifier(),
proposedDeliveryDate, quote);
break;
}
}
// let the interactive quote handler know that
// we have handled a quote for a rfq
// we block further quotes for this rfq
if (order != null)
{
super.interactiveQuoteHandler.addAnsweredQuote(order
.getQuote());
}
this.sendContent(order, 0.0);
// remove the quotes from the content store
for (int i = 0; i < quotes.size(); i++)
{
super.getGameContentStore().removeContent(
(Content) quotes.get(i), false);
}
} catch (Exception exception)
{
Logger.severe(this, "notify", exception);
}
return;
}
if (event.getType().equals(GameManufacturerInteractive.PAY_BILL_EVENT))
=====================================================================
Found a 47 line (258 tokens) duplication in the following files:
Starting at line 86 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameleader\dialogs\content\components\BillContentPanel.java
Starting at line 83 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameleader\dialogs\content\components\PaymentContentPanel.java
}
if (this.content != null)
{
this.initialize();
} else
{
Logger.severe(this, "<init>",
"Could not extract content from received content of class: "
+ content.getClass());
}
}
/**
* @see org.gscg.gameleader.dialogs.components.AbstractPanel#initialize()
*/
protected void initialize()
{
JPanel labelPanel = new JPanel();
// col1, row1, col2, row2, hAlign, vAlign
double[][] nameLabelPanelLayout = {
{TableLayoutConstants.FILL, TableLayoutConstants.FILL},
{20, 20, 20, 20, 20, 20, 20}};
labelPanel.setLayout(new TableLayout(nameLabelPanelLayout));
labelPanel.setBackground(Color.WHITE);
JLabel senderLabel = super.getFormattedLabel("sender name");
labelPanel.add(senderLabel, "0,0,L,C");
JLabel senderNameLabel = super.getFormattedLabel(this.content
.getSender().getName());
senderNameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
labelPanel.add(senderNameLabel, "1,0,R,C");
JLabel receiverLabel = super.getFormattedLabel("receiver name");
labelPanel.add(receiverLabel, "0,1,L,C");
JLabel receiverNameLabel = super.getFormattedLabel(this.content
.getReceiver().getName());
receiverNameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
labelPanel.add(receiverNameLabel, "1,1,R,C");
JLabel productLabel = super.getFormattedLabel("product name");
labelPanel.add(productLabel, "0,2,L,C");
JLabel productNameLabel = super.getFormattedLabel(this.content
.getProduct().getName());
productNameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
labelPanel.add(productNameLabel, "1,2,R,C");
JLabel paymentLabel = super.getFormattedLabel("payment");
=====================================================================
Found a 53 line (257 tokens) duplication in the following files:
Starting at line 169 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameleader\dialogs\content\components\OrderBasedOnQuoteContentPanel.java
Starting at line 174 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameleader\dialogs\content\components\QuoteContentPanel.java
this.content.getProposedDeliveryDate(), this.simulator));
earliestDeliveryNameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
labelPanel.add(earliestDeliveryNameLabel, "1,5,R,C");
// the information about the content
URL description = URLResource.getResource("/"
+ this.content.getClass().getName().substring(
this.content.getClass().getName().lastIndexOf(".") + 1)
+ ".html");
JEditorPane descriptionPane = null;
try
{
descriptionPane = new JEditorPane(description);
} catch (IOException exception)
{
description = URLResource.getResource("/general_info.html");
try
{
descriptionPane = new JEditorPane(description);
} catch (IOException exception2)
{
Logger.warning(this, "initialize", exception2);
descriptionPane = new JEditorPane();
}
}
descriptionPane.setAlignmentY(Component.CENTER_ALIGNMENT);
descriptionPane.setAlignmentX(Component.TOP_ALIGNMENT);
descriptionPane.setEditable(false);
descriptionPane.setFocusable(false);
descriptionPane.setBackground(Color.WHITE);
descriptionPane.setVisible(true);
JScrollPane scrollPane = new JScrollPane(descriptionPane);
scrollPane
.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
scrollPane
.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
// setup the panel
double[][] panelLayout = {{TableLayoutConstants.FILL},
{120, TableLayoutConstants.FILL}};
super.setLayout(new TableLayout(panelLayout));
// add the components
super.add(labelPanel, "0,0,L,C");
super.add(scrollPane, "0,1,L,T");
// we need this to make sure the description pane
// is visible at the first time a dialog is opened
super.validate();
super.doLayout();
}
}
=====================================================================
Found a 47 line (256 tokens) duplication in the following files:
Starting at line 103 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameleader\dialogs\content\components\OrderBasedOnQuoteContentPanel.java
Starting at line 77 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameleader\dialogs\content\components\OrderConfirmationContentPanel.java
}
if (this.content != null)
{
this.initialize();
} else
{
Logger.severe(this, "<init>",
"Could not extract content from received content of class: "
+ content.getClass());
}
}
/**
* @see org.gscg.gameleader.dialogs.components.AbstractPanel#initialize()
*/
protected void initialize()
{
JPanel labelPanel = new JPanel();
// col1, row1, col2, row2, hAlign, vAlign
double[][] nameLabelPanelLayout = {
{TableLayoutConstants.FILL, TableLayoutConstants.FILL},
{20, 20, 20, 20, 20, 20}};
labelPanel.setLayout(new TableLayout(nameLabelPanelLayout));
labelPanel.setBackground(Color.WHITE);
JLabel senderLabel = super.getFormattedLabel("sender name");
labelPanel.add(senderLabel, "0,0,L,C");
JLabel senderNameLabel = super.getFormattedLabel(this.content
.getSender().getName());
senderNameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
labelPanel.add(senderNameLabel, "1,0,R,C");
JLabel receiverLabel = super.getFormattedLabel("receiver name");
labelPanel.add(receiverLabel, "0,1,L,C");
JLabel receiverNameLabel = super.getFormattedLabel(this.content
.getReceiver().getName());
receiverNameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
labelPanel.add(receiverNameLabel, "1,1,R,C");
JLabel productLabel = super.getFormattedLabel("product name");
labelPanel.add(productLabel, "0,2,L,C");
JLabel productNameLabel = super.getFormattedLabel(this.content
.getProduct().getName());
productNameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
labelPanel.add(productNameLabel, "1,2,R,C");
JLabel statusLabel = super.getFormattedLabel("status");
=====================================================================
Found a 54 line (254 tokens) duplication in the following files:
Starting at line 126 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameleader\dialogs\content\components\OrderConfirmationContentPanel.java
Starting at line 125 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameleader\dialogs\content\components\ShipmentContentPanel.java
.getCargo().getAmount()
+ "");
statusNameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
labelPanel.add(statusNameLabel, "1,3,R,C");
// the information about the content
URL description = URLResource.getResource("/"
+ this.content.getClass().getName().substring(
this.content.getClass().getName().lastIndexOf(".") + 1)
+ ".html");
JEditorPane descriptionPane = null;
try
{
descriptionPane = new JEditorPane(description);
} catch (IOException exception)
{
description = URLResource.getResource("/general_info.html");
try
{
descriptionPane = new JEditorPane(description);
} catch (IOException exception2)
{
Logger.warning(this, "initialize", exception2);
descriptionPane = new JEditorPane();
}
}
descriptionPane.setAlignmentY(Component.CENTER_ALIGNMENT);
descriptionPane.setAlignmentX(Component.TOP_ALIGNMENT);
descriptionPane.setEditable(false);
descriptionPane.setFocusable(false);
descriptionPane.setBackground(Color.WHITE);
descriptionPane.setVisible(true);
JScrollPane scrollPane = new JScrollPane(descriptionPane);
scrollPane
.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
scrollPane
.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
// setup the panel
double[][] panelLayout = {{TableLayoutConstants.FILL},
{80, TableLayoutConstants.FILL}};
super.setLayout(new TableLayout(panelLayout));
// add the components
super.add(labelPanel, "0,0,L,C");
super.add(scrollPane, "0,1,L,T");
// we need this to make sure the description pane
// is visible at the first time a dialog is opened
super.validate();
super.doLayout();
}
}
=====================================================================
Found a 54 line (253 tokens) duplication in the following files:
Starting at line 324 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameactors\GameDistributorInteractive.java
Starting at line 325 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameactors\GameManufacturerInteractive.java
FaxDevice fax = new FaxDevice("GameManufacturerFax", this.simulator);
addSendingDevice(fax);
MessageHandlerInterface secretary = new HandleAllMessages(this);
addReceivingDevice(fax, secretary, hourDist);
} catch (RemoteException remoteException)
{
Logger.severe(this, "addDevices", remoteException);
}
}
/**
* @see org.gscg.common.interactionlayer.AnnounceInterface#announce(nl.tudelft.simulation.event.EventType,
* boolean)
*/
public void announce(final EventType eventType, final boolean announce)
{
if (eventType.equals(StockInterface.STOCK_CHANGE_EVENT))
{
List products = super.getProductsOnStock();
for (int i = 0; i < products.size(); i++)
{
Product product = (Product) products.get(i);
this.stock.getActualAmount(product);
StockUpdateData data = new StockUpdateData(product.getName(),
this.stock.getActualAmount(product), this.stock
.getClaimedAmount(product), this.stock
.getOrderedAmount(product));
try
{
this.singleUserInteractionLayer.notifyAnnounced(new Event(
StockInterface.STOCK_CHANGE_EVENT, this, data));
} catch (RemoteException remoteException)
{
Logger.severe(this, "announce", remoteException);
}
}
return;
}
new ReceivedUnknownEventException(this, "announce", eventType);
}
/**
* @see nl.tudelft.simulation.event.EventListenerInterface#notify(nl.tudelft.simulation.event.EventInterface)
*/
public void notify(final EventInterface event)
{
if (event.getType().equals(GlobalRowOrColumnNumber.UPDATE_CURRENT_DAY))
{
// we use these events to update the statistics on a daily basis
this.sendStockUpdateEvent();
this.bankAccount.sendBalanceUpdateEvent();
return;
}
if (event.getType().equals(
=====================================================================
Found a 73 line (252 tokens) duplication in the following files:
Starting at line 368 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\interactionlayer\DistributorSingleUserInteractionLayer.java
Starting at line 372 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\interactionlayer\ManufacturerSingleUserInteractionLayer.java
+ this.owner.getName()
+ "\" is ready to play.");
return;
}
new ReceivedUnknownEventException(this, "getCache1",
eventType);
}
}
} else
{
// no announce, for example for updating statistics
if (this.announceObjects.containsKey(eventType.toString()))
{
AnnounceInterface object = (AnnounceInterface) this.announceObjects
.get(eventType.toString());
object.announce(eventType, false);
return;
}
// the events fired by the client
if (this.eventsSentByClient.contains(eventType))
{
if (remoteEventProducer != null)
{
((RemoteEventProducerInterface) remoteEventProducer)
.addListener(this.remoteEventListener, eventType,
false);
System.out.println("eveny sent by client event: "
+ eventType);
}
return;
}
new ReceivedUnknownEventException(this, "getCache2", eventType);
}
}
/**
* @see nl.tudelft.simulation.event.EventListenerInterface#notify(nl.tudelft.simulation.event.EventInterface)
*/
public void notify(final EventInterface event) throws RemoteException
{
// we only use the commented code for testing
if (this.clientIsReady)
{
// if (this.eventTypes.contains(event.getType()))
// {
super.fireEvent(event);
// return;
// }
// if (this.eventsSentByClient.contains(event.getType()))
// {
// super.fireEvent(event);
// return;
// }
// new ReceivedUnknownEventException(this, event.getType());
} else
{
// only these messages must be forwarded to be stored
if (event.getType().equals(SocialMessaging.RECEIVE_SOCIAL_MESSAGE)
|| event.getType().equals(
SocialMessaging.SOCIAL_MESSAGE_SENT)
|| event.getType().equals(
SocialMessaging.UPDATE_SENT_SOCIAL_MESSAGE)
|| event.getType().equals(
SocialMessaging.UPDATE_RECEIVED_SOCIAL_MESSAGE))
{
this.fireEvent(new Event(event.getType(), this, event
.getContent()));
return;
}
if (this.shouldBeCaching)
{
Logger.info(this, "notify",
=====================================================================
Found a 92 line (251 tokens) duplication in the following files:
Starting at line 571 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\interactionlayer\DistributorSingleUserInteractionLayer.java
Starting at line 575 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\interactionlayer\ManufacturerSingleUserInteractionLayer.java
return ((GameManufacturer) this.owner).getInitialRFQData(productName);
}
/**
* @see org.gscg.common.interactionlayer.GlobalInteractionLayerInterface#getTotalNumberOfDays()
*/
public int getTotalNumberOfDays() throws RemoteException
{
return GlobalRowOrColumnNumber.getNumberOfDays();
}
/**
* @see org.gscg.singleuser.interactionlayer.SingleUserInteractionLayerInterface#getOwner()
*/
public SupplyChainActor getOwner()
{
return this.owner;
}
/**
* @see org.gscg.singleuser.interactionlayer.SingleUserInteractionLayerInterface#getSimulator()
*/
public SimulatorInterface getSimulator()
{
return this.simulator;
}
//
// PRIVATE METHODS *********************************************************
//
/**
* Method isReady.
*
* @param ready true if the client is connected, false otherwise
*/
private void isReady(final boolean ready)
{
this.clientIsReady = ready;
this.yellowPage.updateInteractiveOnlineStatus(this.owner, ready, false);
}
/**
* writes a serializable method to stream
*
* @param out the outputstream
* @throws IOException on IOException
*/
private synchronized void writeObject(final ObjectOutputStream out)
throws IOException
{
// we set our status to offline;
this.yellowPage.updateInteractiveOnlineStatus(this.owner, false, true);
out.defaultWriteObject();
out.writeObject(this.simulator.getReplication().getRunControl()
.getTreatment().getProperties());
// we reset our status before saving
this.yellowPage.updateInteractiveOnlineStatus(this.owner,
this.clientIsReady, true);
}
/**
* reads a serializable method from stream
*
* @param in the inputstream
*/
private synchronized void readObject(final java.io.ObjectInputStream in)
{
try
{
in.defaultReadObject();
try
{
UnicastRemoteObject.exportObject(this);
} catch (RemoteException remoteException)
{
Logger.severe(this, "<init>", remoteException);
}
// custom deserialize methods
this.remoteEventListener = new RemoteEventListener(this);
this.semaphore = new Object();
new InitialEventContext().bind(this.id, this);
this.clientIsReady = false;
} catch (Exception exception)
{
Logger.severe(this, "readObject", exception);
}
}
}
=====================================================================
Found a 55 line (248 tokens) duplication in the following files:
Starting at line 326 of D:\java\gaming\supplychain-game\src\java\org\gscg\common\gui\components\AmountSpinnerPanel.java
Starting at line 265 of D:\java\gaming\supplychain-game\src\java\org\gscg\common\gui\components\EstimatedTransportTimePanel.java
public IncreaseStepSizeThread(final EstimatedTransportTimePanel owner)
{
this.owner = owner;
}
/**
* @see java.lang.Runnable#run()
*/
public void run()
{
super.run();
// if only cicked once, we must sleep a little
// while and than check whether we should run
try
{
Thread.sleep(500);
int count = 0;
while (this.owner.pressed)
{
count++;
double stepSize = this.owner.stepSize * count;
if (stepSize > (this.owner.maximum - ((Double) this.owner.spinner
.getValue()).doubleValue()))
{
stepSize = this.owner.maximum
- ((Double) this.owner.spinner.getValue())
.doubleValue();
}
if (stepSize > (((Double) this.owner.spinner.getValue())
.doubleValue() - this.owner.minimum))
{
stepSize = ((Double) this.owner.spinner.getValue())
.doubleValue()
- this.owner.minimum;
}
SpinnerModel model = new SpinnerNumberModel(
((Double) this.owner.spinner.getValue())
.doubleValue(),
// current value
this.owner.minimum, // min
this.owner.maximum, // max
stepSize); // step
this.owner.spinner.setModel(model);
// we sleep before increasing the time step
Thread.sleep(100);
}
} catch (Exception exception)
{
Logger.severe(this, "run", exception);
}
}
}
}
=====================================================================
Found a 51 line (236 tokens) duplication in the following files:
Starting at line 171 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameleader\dialogs\content\components\OrderBasedOnQuoteContentPanel.java
Starting at line 184 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameleader\dialogs\content\components\RequestForQuoteContentPanel.java
labelPanel.add(latestDeliveryNameLabel, "1,5,R,C");
// the information about the content
URL description = URLResource.getResource("/"
+ this.content.getClass().getName().substring(
this.content.getClass().getName().lastIndexOf(".") + 1)
+ ".html");
JEditorPane descriptionPane = null;
try
{
descriptionPane = new JEditorPane(description);
} catch (IOException exception)
{
description = URLResource.getResource("/general_info.html");
try
{
descriptionPane = new JEditorPane(description);
} catch (IOException exception2)
{
Logger.warning(this, "initialize", exception2);
descriptionPane = new JEditorPane();
}
}
descriptionPane.setAlignmentY(Component.CENTER_ALIGNMENT);
descriptionPane.setAlignmentX(Component.TOP_ALIGNMENT);
descriptionPane.setEditable(false);
descriptionPane.setFocusable(false);
descriptionPane.setBackground(Color.WHITE);
descriptionPane.setVisible(true);
JScrollPane scrollPane = new JScrollPane(descriptionPane);
scrollPane
.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
scrollPane
.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
// setup the panel
double[][] panelLayout = {{TableLayoutConstants.FILL},
{120, TableLayoutConstants.FILL}};
super.setLayout(new TableLayout(panelLayout));
// add the components
super.add(labelPanel, "0,0,L,C");
super.add(scrollPane, "0,1,L,T");
// we need this to make sure the description pane
// is visible at the first time a dialog is opened
super.validate();
super.doLayout();
}
}
=====================================================================
Found a 51 line (236 tokens) duplication in the following files:
Starting at line 147 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameleader\dialogs\content\components\BillContentPanel.java
Starting at line 143 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameleader\dialogs\content\components\PaymentContentPanel.java
labelPanel.add(paymentDateNameLabel, "1,4,R,C");
// the information about the content
URL description = URLResource.getResource("/"
+ this.content.getClass().getName().substring(
this.content.getClass().getName().lastIndexOf(".") + 1)
+ ".html");
JEditorPane descriptionPane = null;
try
{
descriptionPane = new JEditorPane(description);
} catch (IOException exception)
{
description = URLResource.getResource("/general_info.html");
try
{
descriptionPane = new JEditorPane(description);
} catch (IOException exception2)
{
Logger.warning(this, "initialize", exception2);
descriptionPane = new JEditorPane();
}
}
descriptionPane.setAlignmentY(Component.CENTER_ALIGNMENT);
descriptionPane.setAlignmentX(Component.TOP_ALIGNMENT);
descriptionPane.setEditable(false);
descriptionPane.setFocusable(false);
descriptionPane.setBackground(Color.WHITE);
descriptionPane.setVisible(true);
JScrollPane scrollPane = new JScrollPane(descriptionPane);
scrollPane
.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
scrollPane
.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
// setup the panel
double[][] panelLayout = {{TableLayoutConstants.FILL},
{100, TableLayoutConstants.FILL}};
super.setLayout(new TableLayout(panelLayout));
// add the components
super.add(labelPanel, "0,0,L,C");
super.add(scrollPane, "0,1,L,T");
// we need this to make sure the description pane
// is visible at the first time a dialog is opened
super.validate();
super.doLayout();
}
}
=====================================================================
Found a 49 line (221 tokens) duplication in the following files:
Starting at line 605 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameactors\GameDistributorInteractive.java
Starting at line 606 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameactors\GameManufacturerInteractive.java
GameManufacturerInteractive.ORDER_CONFIRMATION_SENT_BY_CLIENT_EVENT))
{
SentOrderConfirmationData data = (SentOrderConfirmationData) event
.getContent();
try
{
SupplyChainActor sender = this.globalSupplyChainData
.getSupplyChainActor(data.getSenderName());
SupplyChainActor receiver = this.globalSupplyChainData
.getSupplyChainActor(data.getReceiverName());
Order order = (Order) super.getGameContentStore()
.getContentList(
data.getOrderData().getInternalDemandID(),
Order.class, false).get(0);
if (order == null)
{
Logger.severe(this,
"notify ORDER_CONFIRMATION_SENT_BY_CLIENT_EVENT",
"order not found in ContentStore");
} else
{
OrderConfirmation confirmation = new OrderConfirmation(
sender, receiver, data.getOrderData()
.getInternalDemandID(), order, data
.getConfirmationStatus());
this.sendContent(confirmation, 0.0);
InteractiveOrderHandlerStock handler = new InteractiveOrderHandlerStock(
this, super.stock);
handler.handleOrder(order);
// generate the customer statistics
super.customerStatistics.handleContent(confirmation);
}
return;
} catch (Exception exception)
{
Logger.severe(this, "notify", exception);
}
return;
}
if (event.getType().equals(SimulatorInterface.WARMUP_EVENT))
{
super.humanControlled = true;
super.warmingUp = false;
Logger
.info(
this,
"init",
=====================================================================
Found a 45 line (210 tokens) duplication in the following files:
Starting at line 109 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\handlers\LatLonOrderHandlerStock.java
Starting at line 149 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\handlers\ManufacturerOrderHandlerProduce.java
return false;
}
return true;
}
/**
* Pick and ship the goods.
*
* @param order the order that should be handled
*/
protected void ship(final Order order)
{
Product product = order.getProduct();
double amount = order.getAmount();
try
{
double day = TimeUnit.convert(1.0, TimeUnitInterface.DAY,
super.owner.getSimulator());
if (this.stock.getActualAmount(product) < amount)
{
// try again in one day
Object[] args = new Object[]{order};
SimEventInterface simEvent = new SimEvent(super.owner
.getSimulatorTime()
+ day, this, this, "ship", args);
super.owner.getSimulator().scheduleEvent(simEvent);
} else
{
// tell the stock that we got the claimed amount
this.stock.changeClaimedAmount(order.getProduct(), -order
.getAmount());
// available: make shipment and ship to customer
Cargo cargo = this.stock.getStock(product, amount);
Shipment shipment = new Shipment(super.owner,
order.getSender(), order.getInternalDemandID(), order,
cargo);
shipment.setInTransit(true);
// TODO get the transportation mode from the shipment?
super.owner.sendContent(shipment, TransportMode.PLANE
.transportTime(shipment.getSender(), shipment
.getReceiver()));
=====================================================================
Found a 45 line (204 tokens) duplication in the following files:
Starting at line 151 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\interactionlayer\DistributorSingleUserInteractionLayer.java
Starting at line 152 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\interactionlayer\ManufacturerSingleUserInteractionLayer.java
public ManufacturerSingleUserInteractionLayer(
final SimulatorInterface simulator, final String id,
final SupplyChainActor owner,
final GameGlobalData globalSupplyChainData)
{
super();
try
{
UnicastRemoteObject.exportObject(this);
} catch (RemoteException remoteException)
{
Logger.severe(this, "<init>", remoteException);
}
try
{
this.globalSupplyChainData = globalSupplyChainData;
this.remoteEventListener = new RemoteEventListener(this);
this.simulator = simulator;
this.simulator.addListener(this, SimulatorInterface.START_EVENT);
this.eventTypes.add(SimulatorInterface.START_EVENT);
this.simulator.addListener(this, SimulatorInterface.STOP_EVENT);
this.eventTypes.add(SimulatorInterface.STOP_EVENT);
this.id = id;
this.owner = owner;
this.yellowPage = this.globalSupplyChainData.getYellowPage();
// add actor to the location and name class
this.globalSupplyChainData.getYellowPage().addListener(this,
YellowPage.UPDATE_ACTORS, false);
this.globalSupplyChainData.getYellowPage().addListener(this,
YellowPage.UPDATE_INTERACTIVE_PLAYER_STATUS, false);
//
// initialize components
//
new ProgressDateAndTime(this);
new CurrentRowOrColumnNumber(this);
new SocialMessaging(this, this.yellowPage);
new Economics(this);
new BusinessStock(this);
new BusinessPurchase(this);
new BusinessProduction(this);
=====================================================================
Found a 40 line (198 tokens) duplication in the following files:
Starting at line 342 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameactors\GameManufacturer.java
Starting at line 318 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameactors\GameDistributor.java
Element rootElement = GameDistributor.builder.build(url)
.getRootElement();
HandlerParser.parseAndAddHandler(this, rootElement);
} catch (Exception exception)
{
Logger.severe(this, "addComputerControlledContentHandlers",
exception);
}
// after all handlers have been added we check whether there is an
// internal demand handler for rfq's
if (this.contentHandlers.containsKey(InternalDemand.class))
{
Set resolvedHandlers = (Set) this.contentHandlers
.get(InternalDemand.class);
for (Iterator resolvedHandlersIterator = resolvedHandlers
.iterator(); resolvedHandlersIterator.hasNext();)
{
HandlerInterface handler = (HandlerInterface) resolvedHandlersIterator
.next();
if (handler instanceof InternalDemandHandlerRFQ)
{
Iterator productIterator = this.getStock().iterator();
while (productIterator.hasNext())
{
Product product = (Product) productIterator.next();
Set suppliers = (Set) this.getProductNameToSuppliers()
.get(product.getName());
if (suppliers != null)
{
for (Iterator supplierIterator = suppliers
.iterator(); supplierIterator.hasNext();)
{
((InternalDemandHandlerRFQ) handler)
.addSupplier(product,
(Trader) supplierIterator
.next());
=====================================================================
Found a 39 line (195 tokens) duplication in the following files:
Starting at line 164 of D:\java\gaming\supplychain-game\src\java\org\gscg\experiment\xsd\MarketXSDParser.java
Starting at line 236 of D:\java\gaming\supplychain-game\src\java\org\gscg\experiment\xsd\ScriptXSDParser.java
.getManufacturersArray()[manufacturers])
.getName());
child2.addContent(secondClone);
}
break;
}
break;
}
}
if (element.getValue().equalsIgnoreCase("distributorsEnum"))
{
for (int ii = 0; ii < child.getChildren().size(); ii++)
{
Element child2 = (Element) child.getChildren().get(
ii);
for (int iii = 0; iii < child2.getChildren().size(); iii++)
{
Element clone = (Element) ((Element) child2
.getChildren().get(iii)).clone();
child2.getChildren().clear();
for (int distributors = 0; distributors < Distributors
.getDistributorsArray().length; distributors++)
{
Element secondClone = (Element) clone
.clone();
Attribute attrib = secondClone
.getAttribute("value");
attrib
.setValue((Distributors
.getDistributorsArray()[distributors])
.getName());
child2.addContent(secondClone);
}
break;
}
break;
}
}
=====================================================================
Found a 26 line (194 tokens) duplication in the following files:
Starting at line 108 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameleader\dialogs\content\components\BillContentPanel.java
Starting at line 98 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameleader\dialogs\content\components\OrderConfirmationContentPanel.java
{20, 20, 20, 20, 20, 20}};
labelPanel.setLayout(new TableLayout(nameLabelPanelLayout));
labelPanel.setBackground(Color.WHITE);
JLabel senderLabel = super.getFormattedLabel("sender name");
labelPanel.add(senderLabel, "0,0,L,C");
JLabel senderNameLabel = super.getFormattedLabel(this.content
.getSender().getName());
senderNameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
labelPanel.add(senderNameLabel, "1,0,R,C");
JLabel receiverLabel = super.getFormattedLabel("receiver name");
labelPanel.add(receiverLabel, "0,1,L,C");
JLabel receiverNameLabel = super.getFormattedLabel(this.content
.getReceiver().getName());
receiverNameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
labelPanel.add(receiverNameLabel, "1,1,R,C");
JLabel productLabel = super.getFormattedLabel("product name");
labelPanel.add(productLabel, "0,2,L,C");
JLabel productNameLabel = super.getFormattedLabel(this.content
.getProduct().getName());
productNameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
labelPanel.add(productNameLabel, "1,2,R,C");
JLabel statusLabel = super.getFormattedLabel("status");
=====================================================================
Found a 39 line (189 tokens) duplication in the following files:
Starting at line 147 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameleader\dialogs\content\components\BillContentPanel.java
Starting at line 171 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameleader\dialogs\content\components\OrderBasedOnQuoteContentPanel.java
Starting at line 129 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameleader\dialogs\content\components\OrderConfirmationContentPanel.java
labelPanel.add(statusNameLabel, "1,3,R,C");
// the information about the content
URL description = URLResource.getResource("/"
+ this.content.getClass().getName().substring(
this.content.getClass().getName().lastIndexOf(".") + 1)
+ ".html");
JEditorPane descriptionPane = null;
try
{
descriptionPane = new JEditorPane(description);
} catch (IOException exception)
{
description = URLResource.getResource("/general_info.html");
try
{
descriptionPane = new JEditorPane(description);
} catch (IOException exception2)
{
Logger.warning(this, "initialize", exception2);
descriptionPane = new JEditorPane();
}
}
descriptionPane.setAlignmentY(Component.CENTER_ALIGNMENT);
descriptionPane.setAlignmentX(Component.TOP_ALIGNMENT);
descriptionPane.setEditable(false);
descriptionPane.setFocusable(false);
descriptionPane.setBackground(Color.WHITE);
descriptionPane.setVisible(true);
JScrollPane scrollPane = new JScrollPane(descriptionPane);
scrollPane
.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
scrollPane
.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
// setup the panel
double[][] panelLayout = {{TableLayoutConstants.FILL},
{80, TableLayoutConstants.FILL}};
=====================================================================
Found a 26 line (188 tokens) duplication in the following files:
Starting at line 108 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameleader\dialogs\content\components\BillContentPanel.java
Starting at line 125 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameleader\dialogs\content\components\OrderBasedOnQuoteContentPanel.java
{20, 20, 20, 20, 20, 20}};
labelPanel.setLayout(new TableLayout(nameLabelPanelLayout));
labelPanel.setBackground(Color.WHITE);
JLabel senderLabel = super.getFormattedLabel("sender name");
labelPanel.add(senderLabel, "0,0,L,C");
JLabel senderNameLabel = super.getFormattedLabel(this.content
.getSender().getName());
senderNameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
labelPanel.add(senderNameLabel, "1,0,R,C");
JLabel receiverLabel = super.getFormattedLabel("receiver name");
labelPanel.add(receiverLabel, "0,1,L,C");
JLabel receiverNameLabel = super.getFormattedLabel(this.content
.getReceiver().getName());
receiverNameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
labelPanel.add(receiverNameLabel, "1,1,R,C");
JLabel productLabel = super.getFormattedLabel("product name");
labelPanel.add(productLabel, "0,2,L,C");
JLabel productNameLabel = super.getFormattedLabel(this.content
.getProduct().getName());
productNameLabel.setHorizontalAlignment(SwingConstants.RIGHT);
labelPanel.add(productNameLabel, "1,2,R,C");
JLabel amountLabel = super.getFormattedLabel("amount");
=====================================================================
Found a 45 line (188 tokens) duplication in the following files:
Starting at line 85 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\handlers\InteractiveOrderHandlerStock.java
Starting at line 111 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\handlers\LatLonOrderHandlerStock.java
return true;
}
/**
* Pick and ship the goods.
*
* @param order the order that should be handled
*/
protected void ship(final Order order)
{
Product product = order.getProduct();
double amount = order.getAmount();
try
{
double day = TimeUnit.convert(1.0, TimeUnitInterface.DAY,
super.owner.getSimulator());
if (this.stock.getActualAmount(product) < amount)
{
// try again in one day
Object[] args = new Object[]{order};
SimEventInterface simEvent = new SimEvent(super.owner
.getSimulatorTime()
+ day, this, this, "ship", args);
super.owner.getSimulator().scheduleEvent(simEvent);
} else
{
// tell the stock that we got the claimed amount
this.stock.changeClaimedAmount(order.getProduct(), -order
.getAmount());
// available: make shipment and ship to customer
Cargo cargo = this.stock.getStock(product, amount);
Shipment shipment = new Shipment(super.owner,
order.getSender(), order.getInternalDemandID(), order,
cargo);
shipment.setInTransit(true);
// for now: handle it as a message and "fax" or "email" it
// delay is of course the shipment time
// TODO get the transportation mode from the shipment?
/*
* super.owner.sendContent(shipment, ((OrderBasedOnQuote) order)
* .getQuote().getProposedDeliveryDate() - ((OrderBasedOnQuote)
* order).getQuote() .getProposedShippingDate());
*/
super.owner.sendContent(shipment, TransportMode.PLANE
=====================================================================
Found a 46 line (185 tokens) duplication in the following files:
Starting at line 108 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\interactionlayer\business\BusinessPurchase.java
Starting at line 106 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\interactionlayer\business\BusinessProduction.java
public BusinessProduction(final SingleUserInteractionLayerInterface owner)
{
super();
this.owner = owner;
// subscribe the owner to events fired from this object
// also add the necessary announce events
for (int i = 0; i < this.eventsToSubscribeOwnerTo.length; i++)
{
this.addListener(this.owner, this.eventsToSubscribeOwnerTo[i]);
try
{
this.owner.addEventType(this.eventsToSubscribeOwnerTo[i]);
this.owner.addEventTypeToAnnounceList(
this.eventsToSubscribeOwnerTo[i], this);
} catch (RemoteException remoteException)
{
Logger.severe(this, "<init>", remoteException);
}
}
}
/**
* Method calculateNumberOfRows.
*
* @param announce indicates whether this is an announce
*/
private void calculateNumberOfRowsDays(final boolean announce)
{
ArrayList dayHeaderValues = GlobalRowOrColumnNumber
.getDayHeaderValues();
List dataList = new ArrayList();
for (int i = 0; i < dayHeaderValues.size(); i++)
{
dataList.add(new BusinessData(0, i, "", (String) dayHeaderValues
.get(i)));
}
if (announce)
{
if (this.productHeadersUpdated)
{
try
{
this.owner
.notifyAnnounced(new Event(
=====================================================================
Found a 39 line (183 tokens) duplication in the following files:
Starting at line 378 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameactors\GameDistributorInteractive.java
Starting at line 379 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameactors\GameManufacturerInteractive.java
GameManufacturerInteractive.RFQ_SENT_BY_CLIENT_EVENT))
{
// make the internal demand
RFQDataSuppliers submitRFQData = (RFQDataSuppliers) event
.getContent();
Product product = this.globalSupplyChainData
.getProduct(submitRFQData.getProductName());
double earliestDeliveryDate = DateIntData.makeSimulationDate(
submitRFQData.getEarliestDelivery(), this.simulator);
double latestDeliveryDate = DateIntData.makeSimulationDate(
submitRFQData.getLatestDelivery(), this.simulator);
// we check whether the simulation date is not already further
// than the delivery dates, if so we ignore the rfq
try
{
if (earliestDeliveryDate > this.simulator.getSimulatorTime())
{
InternalDemand internalDemand = new InternalDemand(this,
product, submitRFQData.getAmount(),
earliestDeliveryDate, latestDeliveryDate);
String[] suppliers = submitRFQData.getSuppliers();
handleContent(internalDemand);
// make the RFQ and send it out to the selected actors
for (int i = 0; i < suppliers.length; i++)
{
SupplyChainActor supplier = this.globalSupplyChainData
.getSupplyChainActor(suppliers[i]);
RequestForQuote rfq = new RequestForQuote(this,
supplier, internalDemand, product,
submitRFQData.getAmount());
this.sendContent(rfq, 0.0);
}
} else
{
Logger
.info(
this,
"notify",
=====================================================================
Found a 27 line (177 tokens) duplication in the following files:
Starting at line 168 of D:\java\gaming\supplychain-game\src\java\org\gscg\experiment\DistributorParser.java
Starting at line 171 of D:\java\gaming\supplychain-game\src\java\org\gscg\experiment\ManufacturerParser.java
+ name);
}
if (element.getChild("nickname", space) != null)
{
nickName = (element.getChildText("nickname", space));
}
if (element.getChild("lat", space) != null)
{
lat = new Double(element.getChildText("lat", space)).doubleValue();
}
if (element.getChild("lon", space) != null)
{
lon = new Double(element.getChildText("lon", space)).doubleValue();
}
if (element.getChild("initial_balance", space) != null)
{
initialBalance = new Double(element.getChildText("initial_balance",
space)).doubleValue();
}
if (element.getChild("fixed_costs_per_game_time_unit", space) != null)
{
fixedCosts = new Double(element.getChildText(
"fixed_costs_per_game_time_unit", space)).doubleValue();
}
if (element.getChild("products", space) != null)
{
products = ManufacturerParser.parseProduct(element.getChild(
=====================================================================
Found a 35 line (172 tokens) duplication in the following files:
Starting at line 160 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameleader\interactionlayer\experiment\ExperimentParser.java
Starting at line 119 of D:\java\gaming\supplychain-game\src\java\org\gscg\experiment\scenario\ScenarioParser.java
Logger.warning(ScenarioParser.class, "parseScenario", exception);
throw new IOException(exception.getMessage());
}
}
// *********************** PRIVATE PARSING FUNCTIONS *******************//
/**
* parses the dateTime
*
* @param value the string value in the yyyy-mm-ddThh:mm:ss format
* @return long the amount of milliseconds since 1970.
*/
private static long parseDateTime(final String value)
{
Calendar calendar = Calendar.getInstance();
String concatDate = value.split("T")[0];
String concatTime = value.split("T")[1];
String[] date = concatDate.split("-");
String[] time = concatTime.split(":");
calendar.set(new Integer(date[0]).intValue(), new Integer(date[1])
.intValue() - 1, new Integer(date[2]).intValue(), new Integer(
time[0]).intValue(), new Integer(time[1]).intValue(),
new Integer(time[2]).intValue());
return calendar.getTimeInMillis();
}
/**
* parses the event
*
* @param element the xml-element
* @return Event
* @throws Exception on failure
*/
private static Event parseEvent(final Element element) throws Exception
=====================================================================
Found a 34 line (172 tokens) duplication in the following files:
Starting at line 171 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\handlers\PCShopOrderHandlerMake.java
Starting at line 176 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\handlers\ManufacturerOrderHandlerProduce.java
} else
{
// tell the stock that we got the claimed amount
this.stock.changeClaimedAmount(order.getProduct(), -order
.getAmount());
// available: make shipment and ship to customer
Cargo cargo = this.stock.getStock(product, amount);
Shipment shipment = new Shipment(super.owner,
order.getSender(), order.getInternalDemandID(), order,
cargo);
shipment.setInTransit(true);
// TODO get the transportation mode from the shipment?
super.owner.sendContent(shipment, TransportMode.PLANE
.transportTime(shipment.getSender(), shipment
.getReceiver()));
//
// send a bill when the shipment leaves...
Bill bill = new Bill(super.owner, order.getSender(), order
.getInternalDemandID(), order, super.owner
.getSimulatorTime()
+ (14.0 * day), cargo.getValue(), "SALE");
super.owner.sendContent(bill, 0.002);
}
} catch (Exception e)
{
Logger.severe(this, "ship", e);
return;
}
}
}
=====================================================================
Found a 25 line (169 tokens) duplication in the following files:
Starting at line 163 of D:\java\gaming\supplychain-game\src\java\org\gscg\experiment\DistributorParser.java
Starting at line 164 of D:\java\gaming\supplychain-game\src\java\org\gscg\experiment\MarketParser.java
GameDistributor[] distributors = null;
Namespace space = element.getNamespace();
if (element.getChild("name", space) != null)
{
name = (element.getChildText("name", space));
}
if (element.getChild("nickname", space) != null)
{
nickName = (element.getChildText("nickname", space));
}
if (element.getChild("lat", space) != null)
{
lat = new Double(element.getChildText("lat", space)).doubleValue();
}
if (element.getChild("lon", space) != null)
{
lon = new Double(element.getChildText("lon", space)).doubleValue();
}
if (element.getChild("initial_balance", space) != null)
{
initialBalance = new Double(element.getChildText("initial_balance",
space)).doubleValue();
}
if (element.getChild("products", space) != null)
=====================================================================
Found a 34 line (168 tokens) duplication in the following files:
Starting at line 80 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\handlers\PCShopOrderHandlerMake.java
Starting at line 79 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\handlers\LatLonOrderHandlerStock.java
}
/**
* @see nl.tudelft.simulation.content.HandlerInterface#handleContent(java.io.Serializable)
*/
public boolean handleContent(final Serializable content)
{
// get the order
Order order = (Order) content;
// send out the confirmation
OrderConfirmation orderConfirmation = new OrderConfirmation(
super.owner, order.getSender(), order.getInternalDemandID(),
order, OrderConfirmation.CONFIRMED);
super.owner.sendContent(orderConfirmation, 0.00001);
// tell the stock that we claimed some amount
this.stock.changeClaimedAmount(order.getProduct(), order.getAmount());
// wait till the right time to start shipping
try
{
// TODO: get shipping times into all orders
double shippingTime = Math.max(super.owner.getSimulatorTime(),
((OrderBasedOnQuote) order).getQuote()
.getProposedShippingDate());
Object[] args = new Object[]{order};
SimEventInterface simEvent = new SimEvent(shippingTime, this, this,
"ship", args);
super.owner.getSimulator().scheduleEvent(simEvent);
} catch (Exception e)
{
Logger.severe(this, "handleContent", e);
return false;
}
return true;
}
=====================================================================
Found a 36 line (159 tokens) duplication in the following files:
Starting at line 569 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameactors\GameDistributorInteractive.java
Starting at line 570 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameactors\GameManufacturerInteractive.java
GameManufacturerInteractive.RFQ_DELETED_BY_CLIENT_EVENT))
{
RFQData data = (RFQData) event.getContent();
try
{
SupplyChainActor receiver = this.globalSupplyChainData
.getSupplyChainActor(data.getReceiverName());
// find the rfq
List rfqs = super.getGameContentStore().getContentList(
data.getInternalDemandIdentifier(),
RequestForQuote.class, false);
RequestForQuote rfq = null;
for (int i = 0; i < rfqs.size(); i++)
{
RequestForQuote result = (RequestForQuote) rfqs.get(i);
if (result.getReceiver().getName().equalsIgnoreCase(
receiver.getName()))
{
rfq = result;
break;
}
}
// delete the rfq from the erp sysem
super.getGameContentStore().removeContent(rfq, false);
} catch (Exception exception)
{
Logger.severe(this, "notify", exception);
}
return;
}
if (event
.getType()
.equals(
=====================================================================
Found a 26 line (159 tokens) duplication in the following files:
Starting at line 135 of D:\java\gaming\supplychain-game\src\java\org\gscg\experiment\ProductParser.java
Starting at line 164 of D:\java\gaming\supplychain-game\src\java\org\gscg\experiment\ProductParser.java
if (element.getName().equalsIgnoreCase("productwithbom"))
{
Namespace space = element.getNamespace();
if (element.getChild("name", space) != null)
{
name = (element.getChildText("name", space));
}
if (element.getChild("unit", space) != null)
{
unit = ProductParser.parseUnit(element.getChildText("unit"));
}
if (element.getChild("baseprice", space) != null)
{
baseprice = new Double(element.getChildText("baseprice"))
.doubleValue();
}
if (element.getChild("averageunitweight", space) != null)
{
averageUnitWeight = new Double(element
.getChildText("averageunitweight")).doubleValue();
}
if (element.getChild("depreciation", space) != null)
{
depreciation = new Double(element.getChildText("depreciation"))
.doubleValue();
}
=====================================================================
Found a 40 line (156 tokens) duplication in the following files:
Starting at line 90 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameleader\dialogs\content\components\ContentDialog.java
Starting at line 89 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameleader\dialogs\actor\components\ActorDialog.java
public ActorDialog(final Window parent, final String title,
final Component dialog)
{
super();
this.parent = parent;
this.init(title, dialog);
}
/**
* initializes the dialog
*
* @param title the title of the dialog
* @param dialog the table to display
*/
private void init(final String title, final Component dialog)
{
this.setModal(false);
this.setTitle(title);
this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
this.getContentPane().setLayout(new BorderLayout());
JScrollPane pane = new JScrollPane(dialog,
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
pane.setBackground(Color.WHITE);
this.getContentPane().add(pane, BorderLayout.CENTER);
this.getContentPane().setBackground(Color.WHITE);
this.pack();
setRelativeLocation();
this.setVisible(true);
}
/**
* Initializes the location of this dialog relative to its parent window if
* any.
*/
private void setRelativeLocation()
{
setLocationRelativeTo(this.parent);
}
}
=====================================================================
Found a 47 line (154 tokens) duplication in the following files:
Starting at line 200 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\handlers\CommittedOrderHandler.java
Starting at line 266 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\handlers\ConfirmedProductionHandler.java
calendar.set(date.getYear(), date.getMonth(), date.getDay());
Calendar startCalendar = Calendar.getInstance();
startCalendar.setTimeInMillis(GlobalRowOrColumnNumber
.getStartTime());
// calculcate difference between startCalendar and order date
int yearDiffence = calendar.get(Calendar.YEAR)
- startCalendar.get(Calendar.YEAR);
// reset old additional values
this.additionalDays = 0;
this.additionalWeeks = 0;
this.additionalMonths = 0;
while (yearDiffence > 0)
{
startCalendar.set(Calendar.YEAR, startCalendar
.get(Calendar.YEAR) + 1);
this.additionalDays = startCalendar
.getActualMaximum(Calendar.DAY_OF_YEAR);
this.additionalWeeks += 52;
this.additionalMonths += 12;
yearDiffence--;
}
// handle per day
this.handlePerDay(data, calendar);
// handle per week
this.handlePerWeek(data, calendar);
// handle per month
this.handlePerMonth(data, calendar);
return;
}
new ReceivedUnknownEventException(this, "notify", event.getType());
}
/**
* handles an orderconfirmation per day
*
* @param data the data
* @param calendar the calendar
*/
private void handlePerDay(final ProductionStartedData data,
=====================================================================
Found a 82 line (152 tokens) duplication in the following files:
Starting at line 238 of D:\java\gaming\supplychain-game\src\java\org\gscg\common\gui\components\AmountSpinnerPanel.java
Starting at line 177 of D:\java\gaming\supplychain-game\src\java\org\gscg\common\gui\components\EstimatedTransportTimePanel.java
}
/**
* @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
*/
public void mouseClicked(final MouseEvent e)
{
// nothing to do
}
/**
* @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent)
*/
public void mouseEntered(final MouseEvent e)
{
// nothing to do
}
/**
* @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent)
*/
public void mouseExited(final MouseEvent e)
{
// nothing to do
}
/**
* @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
*/
public void mousePressed(final MouseEvent e)
{
this.pressed = true;
this.increaseThread = new IncreaseStepSizeThread(this);
this.increaseThread.start();
}
/**
* @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
*/
public void mouseReleased(final MouseEvent e)
{
this.pressed = false;
try
{
this.increaseThread = null;
// reset the spinner model
SpinnerModel model = new SpinnerNumberModel(((Double) this.spinner
.getValue()).doubleValue(), // initial
// value
this.minimum, // min
this.maximum, // max
this.stepSize); // step
this.spinner.setModel(model);
} catch (Exception exception)
{
Logger.severe(this, "mouseReleased", exception);
}
}
/**
* A thread used to increase the stepsize while the mouse button (either
* increase or decrease) is being pressed.
* <p>
* Copyright (c) 2003-2005 Delft University of Technology, Jaffalaan 5, 2628
* BX Delft, the Netherlands. All rights reserved.
*
* See for project information <a href="http://www.simulation.tudelft.nl/">
* www.simulation.tudelft.nl </a>.
*
* The source code and binary code of this software is proprietary
* information of Delft University of Technology.
*
* @author <a
* href="http://www.tbm.tudelft.nl/webstaf/stijnh/index.htm">Stijn-Pieter
* van Houten </a>
* @version $Revision: 1.1 $ $Date: 2005/06/16 12:33:54 $
* @since 1.0.6
*/
private class IncreaseStepSizeThread extends Thread
{
/** the owner */
private EstimatedTransportTimePanel owner = null;
=====================================================================
Found a 50 line (152 tokens) duplication in the following files:
Starting at line 60 of D:\java\gaming\supplychain-game\src\java\org\gscg\experiment\xsd\MarketXSDParser.java
Starting at line 67 of D:\java\gaming\supplychain-game\src\java\org\gscg\experiment\xsd\ScriptXSDParser.java
public ScriptXSDParser()
{
super();
this.parse();
}
/**
* starts parsing
*/
private void parse()
{
try
{
// some experiment objects
Experiment experiment = TestExperiment.createExperiment();
DEVSSimulatorInterface simulator = new DEVSSimulator();
experiment.setSimulator(simulator);
experiment.setModel(new TestModel(experiment));
try
{
simulator.initialize(experiment.getTreatments()[0]
.getRunControl().getReplications()[0]);
} catch (Exception e)
{
e.printStackTrace();
}
//
// create the products
//
if (Products.getProductsArray().length == 0)
{
try
{
String xsd = URLResource.getResource("/product.xsd")
.toExternalForm();
ProductParser.parseProducts(xsd, URLResource
.getResource("/products.xml"));
} catch (Exception exception)
{
Logger.severe(this, "<init>", exception);
}
}
//
// create the manufacturers
//
if (Manufacturers.getManufacturersArray().length == 0)
=====================================================================
Found a 25 line (147 tokens) duplication in the following files:
Starting at line 133 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\handlers\CommittedOrderHandler.java
Starting at line 133 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\handlers\ConfirmedOrderHandler.java
public ConfirmedOrderHandler(final SingleUserInteractionLayerInterface owner)
{
super();
this.owner = owner;
try
{
this.contentStore = ((GameInteractiveActorRoleInterface) this.owner
.getOwner()).getGameContentStore();
// set the week and year
Calendar calendar = Calendar.getInstance();
double simTime = this.owner.getSimulator().getSimulatorTime();
// convert the simtime
double convertedTime = TimeUnit.convert(simTime, this.owner
.getSimulator().getReplication().getRunControl()
.getTreatment().getTimeUnit(),
TimeUnitInterface.MILLISECOND);
double startTime = this.owner.getSimulator().getReplication()
.getRunControl().getTreatment().getStartTime();
calendar.setTimeInMillis((long) (convertedTime + startTime));
} catch (RemoteException remoteException)
{
Logger.severe(this, "ConfirmedOrderHandler", remoteException);
=====================================================================
Found a 22 line (144 tokens) duplication in the following files:
Starting at line 169 of D:\java\gaming\supplychain-game\src\java\org\gscg\experiment\MarketParser.java
Starting at line 157 of D:\java\gaming\supplychain-game\src\java\org\gscg\experiment\SupplierParser.java
System.out.println("SupplierParser: Parsing supplier: " + name);
}
if (element.getChild("nickname", space) != null)
{
nickName = (element.getChildText("nickname", space));
}
if (element.getChild("lat", space) != null)
{
lat = new Double(element.getChildText("lat", space)).doubleValue();
}
if (element.getChild("lon", space) != null)
{
lon = new Double(element.getChildText("lon", space)).doubleValue();
}
if (element.getChild("initial_balance", space) != null)
{
initialBalance = new Double(element.getChildText("initial_balance",
space)).doubleValue();
}
if (element.getChild("products", space) != null)
{
products = SupplierParser.parseProduct(element.getChild("products",
=====================================================================
Found a 53 line (136 tokens) duplication in the following files:
Starting at line 799 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameactors\GameDistributorInteractive.java
Starting at line 800 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameactors\GameManufacturerInteractive.java
Element rootElement = GameManufacturer.builder.build(url)
.getRootElement();
HandlerParser.parseAndAddHandler(this, rootElement);
} catch (Exception exception)
{
Logger.severe(this, "addInteractiveContentHandlers", exception);
}
}
// private methods
/**
* Method sendStockUpdateEvent fires an update for all the products
* available in the stock
*/
private void sendStockUpdateEvent()
{
for (Iterator i = this.stock.iterator(); i.hasNext();)
{
this.stock.sendStockUpdateEvent((Product) i.next());
}
}
/**
* writes a serializable method to stream
*
* @param out the outputstream
* @throws IOException on IOException
*/
private synchronized void writeObject(final ObjectOutputStream out)
throws IOException
{
out.defaultWriteObject();
}
/**
* reads a serializable method from stream
*
* @param in the inputstream
*/
private synchronized void readObject(final java.io.ObjectInputStream in)
{
try
{
in.defaultReadObject();
// check whether we are in an interactive mode or
// computer-controlled mode
// read properties
Properties properties = new Properties();
try
{
properties.load(URLResource
.getResourceAsStream("/manufacturer.properties"));
=====================================================================
Found a 20 line (136 tokens) duplication in the following files:
Starting at line 157 of D:\java\gaming\supplychain-game\src\java\org\gscg\experiment\SupplierParser.java
Starting at line 171 of D:\java\gaming\supplychain-game\src\java\org\gscg\experiment\ManufacturerParser.java
+ name);
}
if (element.getChild("nickname", space) != null)
{
nickName = (element.getChildText("nickname", space));
}
if (element.getChild("lat", space) != null)
{
lat = new Double(element.getChildText("lat", space)).doubleValue();
}
if (element.getChild("lon", space) != null)
{
lon = new Double(element.getChildText("lon", space)).doubleValue();
}
if (element.getChild("initial_balance", space) != null)
{
initialBalance = new Double(element.getChildText("initial_balance",
space)).doubleValue();
}
if (element.getChild("fixed_costs_per_game_time_unit", space) != null)
=====================================================================
Found a 21 line (135 tokens) duplication in the following files:
Starting at line 237 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameactors\GameManufacturer.java
Starting at line 227 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameactors\GameDistributor.java
if (!this.productNameToSuppliers.containsKey(productOnStock
.getName()))
{
this.productNameToSuppliers.put(productOnStock.getName(),
new HashSet());
}
Set set = (Set) this.productNameToSuppliers.get(productOnStock
.getName());
set.add(trader);
this.productNameToSuppliers.put(productOnStock.getName(), set);
}
}
// give the retailer some stock
Stock stock = new Stock(this);
for (int i = 0; i < product.length; i++)
{
stock.addStock(product[i], amount[i].doubleValue(), amount[i]
.doubleValue()
* product[i].getUnitMarketPrice());
}
=====================================================================
Found a 20 line (134 tokens) duplication in the following files:
Starting at line 168 of D:\java\gaming\supplychain-game\src\java\org\gscg\experiment\DistributorParser.java
Starting at line 157 of D:\java\gaming\supplychain-game\src\java\org\gscg\experiment\SupplierParser.java
System.out.println("SupplierParser: Parsing supplier: " + name);
}
if (element.getChild("nickname", space) != null)
{
nickName = (element.getChildText("nickname", space));
}
if (element.getChild("lat", space) != null)
{
lat = new Double(element.getChildText("lat", space)).doubleValue();
}
if (element.getChild("lon", space) != null)
{
lon = new Double(element.getChildText("lon", space)).doubleValue();
}
if (element.getChild("initial_balance", space) != null)
{
initialBalance = new Double(element.getChildText("initial_balance",
space)).doubleValue();
}
if (element.getChild("products", space) != null)
=====================================================================
Found a 38 line (133 tokens) duplication in the following files:
Starting at line 218 of D:\java\gaming\supplychain-game\src\java\org\gscg\experiment\DistributorParser.java
Starting at line 219 of D:\java\gaming\supplychain-game\src\java\org\gscg\experiment\MarketParser.java
}
/**
* Parses a element representing a list of products
*
* @param element the element to parse
* @return returns an array with products
* @throws Exception thrown in case of an unknown name
*/
private static Product[] parseProduct(final Element element)
throws Exception
{
List products = element.getChildren();
List result = new ArrayList();
for (int i = 0; i < products.size(); i++)
{
Element product = (Element) products.get(i);
Namespace space = element.getNamespace();
String name = null;
if (product.getChild("product", space) != null)
{
name = (product.getChildText("product", space));
}
result.add(Products.getProduct(name));
}
return (Product[]) result.toArray(new Product[result.size()]);
}
/**
* Parses a element representing a list of demands
*
* @param element the element to parse
* @param products the products for the demands
* @param simulator the simulator
* @return returns an array with demands
* @throws Exception thrown in case of an unknown name
*/
private static Demand[] parseDemand(final Element element,
=====================================================================
Found a 35 line (131 tokens) duplication in the following files:
Starting at line 136 of D:\java\gaming\supplychain-game\src\java\org\gscg\common\gui\components\PriceSpinnerPanel.java
Starting at line 126 of D:\java\gaming\supplychain-game\src\java\org\gscg\common\gui\components\TransportationCostsSpinnerPanel.java
}
// tweak the spinner's formatted text field.
JFormattedTextField ftf = null;
ftf = SpinnerUtilities.getTextField(this.spinner);
if (ftf != null)
{
ftf.setColumns(6); // specify more width than we need
ftf.setHorizontalAlignment(SwingConstants.RIGHT);
ftf.setEditable(false);
ftf.setBackground(new Color(255, 255, 255));
}
}
/**
* @return Returns the spinner.
*/
public JSpinner getSpinner()
{
return this.spinner;
}
/**
* @see javax.swing.event.ChangeListener#stateChanged(javax.swing.event.ChangeEvent)
*/
public void stateChanged(final ChangeEvent e)
{
if (((JSpinner) e.getSource()).getName().equalsIgnoreCase(
AmountSpinnerPanel.AMOUNT_SPINNER_NAME))
{
// we got a changed amount
this.amount = ((Double) ((JSpinner) e.getSource()).getValue())
.doubleValue();
}
=====================================================================
Found a 35 line (127 tokens) duplication in the following files:
Starting at line 289 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameactors\GameDistributorInteractive.java
Starting at line 291 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameactors\GameManufacturerInteractive.java
+ this.name + " in properties: ." + properties);
}
//
// CHARTS
//
try
{
if (this.simulator instanceof AnimatorInterface)
{
XYChart bankChart = new XYChart(this.simulator, "BankAccount "
+ this.name);
bankChart.add("bank account", this.bankAccount,
BankAccount.BANK_ACCOUNT_CHANGED_EVENT);
}
} catch (RemoteException remoteException)
{
Logger.severe(this, "init", remoteException);
}
}
/**
* @see org.gscg.gameactors.GameManufacturer#addDevices()
*/
protected void addDevices()
{
try
{
StreamInterface stream = this.simulator.getReplication().getStream(
"default");
double hour = TimeUnit.convert(1.0, TimeUnitInterface.HOUR,
this.simulator);
DistContinuous hourDist = new DistConstant(stream, hour);
// give the actor a fax device which is checked every hour
FaxDevice fax = new FaxDevice("GameManufacturerFax", this.simulator);
=====================================================================
Found a 23 line (126 tokens) duplication in the following files:
Starting at line 479 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameactors\GameDistributorInteractive.java
Starting at line 480 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameactors\GameManufacturerInteractive.java
if (event.getType().equals(GameManufacturerInteractive.PAY_BILL_EVENT))
{
BillData data = (BillData) event.getContent();
Bill bill = (Bill) super.getGameContentStore().getContentList(
data.getInternalDemandID(), Bill.class, false).get(0);
if (bill == null)
{
Logger.severe(this, "notify PAY_BILL_EVENT",
"bill not found in ContentStore");
} else
{
// we pay the bill
this.pay(bill);
// create the payment and send it out
Payment payment = new Payment(bill.getReceiver(), bill
.getSender(), bill.getInternalDemandID(), bill, bill
.getPrice());
this.sendContent(payment, 0.0);
}
return;
}
if (event.getType().equals(
=====================================================================
Found a 52 line (121 tokens) duplication in the following files:
Starting at line 283 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameactors\GameMarket.java
Starting at line 270 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameactors\GameSupplier.java
super.sendContent(content, administrativeDelay);
}
/**
* @see nl.tudelft.simulation.dsol.animation.LocatableInterface#getBounds()
*/
public Bounds getBounds()
{
return new BoundingBox(1.0, 1.0, 0.0);
}
/**
* @return Returns the smallMapLocation.
*/
public DirectedPoint getSmallMapLocation()
{
return this.smallMapLocation;
}
/**
* @param smallMapLocation The smallMapLocation to set.
*/
public void setSmallMapLocation(final DirectedPoint smallMapLocation)
{
this.smallMapLocation = smallMapLocation;
}
/**
* @see nl.tudelft.simulation.actor.ActorInterface#getName()
*/
public String getName()
{
return this.name;
}
/**
* @return Returns the animation
*/
protected GisActorAnimation getAnimation()
{
return this.animation;
}
/**
* @see nl.tudelft.simulation.supplychain.actor.SupplyChainActor#calculateDistance(nl.tudelft.simulation.supplychain.actor.SupplyChainActor)
*/
public double calculateDistance(final SupplyChainActor actor)
{
return new CalculateLatLonDistance().getDistance(new Point2d(
this.location.x, this.location.y), new Point2d(actor
.getLocation().x, actor.getLocation().y));
}
=====================================================================
Found a 20 line (119 tokens) duplication in the following files:
Starting at line 251 of D:\java\gaming\supplychain-game\src\java\org\gscg\game\GameGlobalData.java
Starting at line 362 of D:\java\gaming\supplychain-game\src\java\org\gscg\game\GameGlobalData.java
double time = Math.round(TimeUnit.convert(this.simulator
.getSimulatorTime(), this.simulator.getReplication()
.getRunControl().getTreatment().getTimeUnit(),
TimeUnitInterface.DAY));
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
String date = DateFormat.getDateTimeInstance().format(
calendar.getTime());
// replace any :
String[] dates = date.split(":");
date = dates[0] + "_" + dates[1] + "_" + dates[2];
// we pause for a brief moment
// this.simulator.stop();
// we write these objects first since they are used to create a
// context
BufferedWriter out = new BufferedWriter(new FileWriter(
=====================================================================
Found a 19 line (119 tokens) duplication in the following files:
Starting at line 177 of D:\java\gaming\supplychain-game\src\java\org\gscg\common\gui\components\AmountSpinnerPanel.java
Starting at line 144 of D:\java\gaming\supplychain-game\src\java\org\gscg\common\gui\components\EstimatedTransportTimePanel.java
Object[] keys = this.spinner.getComponents();
for (int i = 0; i < keys.length; i++)
{
Object obj = this.spinner.getComponents()[i];
if (JButton.class.isAssignableFrom(obj.getClass()))
{
((JButton) obj).addMouseListener(this);
}
}
// tweak the spinner's formatted text field.
this.ftf = null;
this.ftf = SpinnerUtilities.getTextField(this.spinner);
if (this.ftf != null)
{
this.ftf.setColumns(5); // specify more width than we need
this.ftf.setHorizontalAlignment(SwingConstants.RIGHT);
this.ftf.setEditable(false);
=====================================================================
Found a 33 line (118 tokens) duplication in the following files:
Starting at line 128 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameleader\animation2D\DistributedGisActorSingleImageRenderable.java
Starting at line 92 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameleader\animation2D\GisActorAnimation.java
}
/**
* @see nl.tudelft.simulation.dsol.animation.D2.Renderable2DInterface#paint(java.awt.Graphics2D,
* java.awt.geom.Rectangle2D, java.awt.Dimension,
* java.awt.image.ImageObserver)
*/
public synchronized void paint(final Graphics2D graphics,
final Rectangle2D rectangle, final Dimension dimension,
final ImageObserver observer)
{
GridPanel animationPanel = (GridPanel) observer;
double scale = Renderable2DInterface.Util.getScale(animationPanel
.getExtent(), animationPanel.getSize());
// System.out.println("Scale: " + scale);
Point2D screenLocation = null;
try
{
screenLocation = Renderable2DInterface.Util.getScreenCoordinates(
super.source.getLocation().to2D(), animationPanel
.getExtent(), animationPanel.getSize());
} catch (RemoteException remoteException)
{
Logger.severe(this, "paint", remoteException);
}
// we only draw our images if there is a certain zoom level
if (scale < 0.05063)
{
super.setScale(true); // note: setScale(true) is linked to
=====================================================================
Found a 16 line (116 tokens) duplication in the following files:
Starting at line 143 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\handlers\ConfirmedOrderHandler.java
Starting at line 163 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\handlers\ConfirmedProductionHandler.java
Calendar calendar = Calendar.getInstance();
double simTime = this.owner.getSimulator().getSimulatorTime();
// convert the simtime
double convertedTime = TimeUnit.convert(simTime, this.owner
.getSimulator().getReplication().getRunControl()
.getTreatment().getTimeUnit(),
TimeUnitInterface.MILLISECOND);
double startTime = this.owner.getSimulator().getReplication()
.getRunControl().getTreatment().getStartTime();
calendar.setTimeInMillis((long) (convertedTime + startTime));
} catch (RemoteException remoteException)
{
Logger.severe(this, "ConfirmedOrderHandler", remoteException);
}
=====================================================================
Found a 64 line (116 tokens) duplication in the following files:
Starting at line 442 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\interactionlayer\DistributorSingleUserInteractionLayer.java
Starting at line 446 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\interactionlayer\ManufacturerSingleUserInteractionLayer.java
+ this.owner.getName() + " is caching");
// we do not cache time changed events
if (!event.getType().equals(
SimulatorInterface.TIME_CHANGED_EVENT))
{
// TODO should we set a limit to the size of the cache?
// if something goes wrong during initialization; caching
// keeps going on; leading eventually to an out-of-memory
// exception
// temp caching of events
this.cache.add(event);
}
return;
}
}
}
/**
* @see org.gscg.singleuser.interactionlayer.SingleUserInteractionLayerInterface#notifyAnnounced(nl.tudelft.simulation.event.EventInterface)
*/
public void notifyAnnounced(final EventInterface event)
{
this.fireEvent(event);
}
/**
* @see org.gscg.common.interactionlayer.GlobalInteractionLayerInterface#login(nl.tudelft.simulation.event.remote.RemoteEventListenerInterface)
*/
public synchronized boolean login(final RemoteEventListenerInterface client)
throws RemoteException
{
// TODO boolean should be set earlier; simultaneous login is possible
// while saving a game
if (this.clientIsReady)
{
// another player application is logged in
return true;
}
if (this.shouldBeCaching)
{
// another player application is logging in
return true;
}
return false;
}
/**
* Method publicFireEvent.
*
* @param event the event to fire
*/
public void publicFireEvent(final EventInterface event)
{
super.fireEvent(event);
}
/**
* Method fireAllNumberData.
*/
public void fireAllNumberData()
{
((GameManufacturer) this.owner).fireAllNumberData();
=====================================================================
Found a 64 line (116 tokens) duplication in the following files:
Starting at line 88 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\interactionlayer\DistributorSingleUserInteractionLayer.java
Starting at line 89 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\interactionlayer\ManufacturerSingleUserInteractionLayer.java
public class ManufacturerSingleUserInteractionLayer extends
ThreadedEventProducer implements RemoteInteractionLayerInterface,
SingleUserInteractionLayerInterface
{
/** the serial version uid */
private static final long serialVersionUID = 13L;
/** the static list of ids in this game for identification mapping */
protected static Map idMap = new HashMap();
/** the remote event listener */
private transient RemoteEventListener remoteEventListener = null;
/** the id is used by a client to perform a lookup in de remote context */
private String id = "";
/** the simulator */
private SimulatorInterface simulator = null;
/** the owner of the interaction layer */
private SupplyChainActor owner = null;
/** the event types this layer is subscribed to */
private Set eventTypes = new HashSet();
/** the event types this layer is subscribed to */
private Set eventsSentByClient = new HashSet();
/** the semaphore to use for the announce calls */
private transient Object semaphore = new Object();
/** indicates if all announce events have been processed client side */
private boolean clientIsReady = false;
/** the event types this layer is subscribed to */
private Set statisticEventTypes = new TreeSet(new EventTypeComparator());
/** the overall game data */
private GameGlobalData globalSupplyChainData;
/** the yellowpage */
private YellowPage yellowPage = null;
/** maps event types and corresponding announce objects */
private HashMap announceObjects = new HashMap();
/**
* indicates whether caching is necessary (during initialization of a
* client)
*/
private boolean shouldBeCaching = false;
/** the cache to store mesages during intialization of a client */
private ArrayList cache = new ArrayList();
/**
* constructs a new DistributorSingleUserInteractionLayer
*
* @param simulator the simulator
* @param id the id of the single user interaction layer
* @param owner the owner of the interaction layer
* @param globalSupplyChainData the global supply chain data
*/
public ManufacturerSingleUserInteractionLayer(
=====================================================================
Found a 37 line (112 tokens) duplication in the following files:
Starting at line 61 of D:\java\gaming\supplychain-game\src\java\org\gscg\experiment\xsd\DistributorXSDParser.java
Starting at line 60 of D:\java\gaming\supplychain-game\src\java\org\gscg\experiment\xsd\MarketXSDParser.java
public MarketXSDParser()
{
super();
this.parse();
}
/**
* starts parsing
*/
private void parse()
{
try
{
// some experiment objects
Experiment experiment = TestExperiment.createExperiment();
DEVSSimulatorInterface simulator = new DEVSSimulator();
experiment.setSimulator(simulator);
experiment.setModel(new TestModel(experiment));
try
{
simulator.initialize(experiment.getTreatments()[0]
.getRunControl().getReplications()[0]);
} catch (Exception e)
{
e.printStackTrace();
}
//
// create the products
//
if (Products.getProductsArray().length == 0)
{
try
{
String xsd = URLResource.getResource("/product.xsd")
=====================================================================
Found a 15 line (111 tokens) duplication in the following files:
Starting at line 143 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\handlers\CommittedOrderHandler.java
Starting at line 163 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\handlers\ConfirmedProductionHandler.java
Calendar calendar = Calendar.getInstance();
double simTime = this.owner.getSimulator().getSimulatorTime();
// convert the simtime
double convertedTime = TimeUnit.convert(simTime, this.owner
.getSimulator().getReplication().getRunControl()
.getTreatment().getTimeUnit(),
TimeUnitInterface.MILLISECOND);
double startTime = this.owner.getSimulator().getReplication()
.getRunControl().getTreatment().getStartTime();
calendar.setTimeInMillis((long) (convertedTime + startTime));
} catch (RemoteException remoteException)
{
Logger.severe(this, "ConfirmedOrderHandler", remoteException);
=====================================================================
Found a 11 line (108 tokens) duplication in the following files:
Starting at line 754 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameleader\interactionlayer\GameLeaderInteractionLayer.java
Starting at line 1087 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameleader\interactionlayer\GameLeaderInteractionLayer.java
new SingleImageDataElement(element.getClass()
.getName(), element.getSource().toString()
+ element.getSource().hashCode(), array[1],
object.getSource().getLocation(),
new Dimension(object.getImages()[0]
.getIconWidth(),
object.getImages()[0]
.getIconHeight()), object
.isFlip(), object.getOrientation(),
object.isRotate(), object.isScale(), object
.isTranslate()));
=====================================================================
Found a 28 line (106 tokens) duplication in the following files:
Starting at line 432 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\handlers\ConfirmedOrderHandler.java
Starting at line 510 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\handlers\ConfirmedProductionHandler.java
value = data.getOrder().getAmount();
map.put("" + this.currentMonth, new Double(value));
}
}
// lookup table row
try
{
int rowNumber = 0;
try
{
rowNumber = ((Integer) GlobalRowOrColumnNumber
.getMonthNumberTableRowNumber().get(new Integer(month)))
.intValue();
} catch (NullPointerException nullPointerException)
{
if (this.dateWithinRange(data))
{
Logger.severe(this, "handlePerMonth",
"Date should be in range, but no row found.");
} else
{
// set the scope outside the game
rowNumber = GlobalRowOrColumnNumber.getMonthHeaderValues()
.size() + 10;
}
}
Event event = new Event(
=====================================================================
Found a 28 line (106 tokens) duplication in the following files:
Starting at line 355 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\handlers\ConfirmedOrderHandler.java
Starting at line 428 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\handlers\ConfirmedProductionHandler.java
value = data.getOrder().getAmount();
map.put("" + this.currentWeek, new Double(value));
}
}
// lookup table row
try
{
int rowNumber = 0;
try
{
rowNumber = ((Integer) GlobalRowOrColumnNumber
.getWeekNumberTableRowNumber().get(new Integer(week)))
.intValue();
} catch (NullPointerException nullPointerException)
{
if (this.dateWithinRange(data))
{
Logger.severe(this, "handlePerWeek",
"Date should be in range, but no row found.");
} else
{
// set the scope outside the game
rowNumber = GlobalRowOrColumnNumber.getWeekHeaderValues()
.size() + 10;
}
}
Event event = new Event(
=====================================================================
Found a 29 line (106 tokens) duplication in the following files:
Starting at line 278 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\handlers\ConfirmedOrderHandler.java
Starting at line 346 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\handlers\ConfirmedProductionHandler.java
value = data.getOrder().getAmount();
map.put("" + this.currentDay, new Double(value));
}
}
// lookup table row
try
{
int rowNumber = 0;
try
{
rowNumber = ((Integer) GlobalRowOrColumnNumber
.getDayNumberTableRowNumber().get(new Integer(day)))
.intValue();
} catch (NullPointerException nullPointerException)
{
if (this.dateWithinRange(data))
{
Logger.severe(this, "handlePerDay",
"Date should be in range, but no row found.");
} else
{
// set the scope outside the game
rowNumber = GlobalRowOrColumnNumber.getDayHeaderValues()
.size() + 10;
}
}
Event event = new Event(
=====================================================================
Found a 28 line (106 tokens) duplication in the following files:
Starting at line 438 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\handlers\CommittedOrderHandler.java
Starting at line 510 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\handlers\ConfirmedProductionHandler.java
value = data.getOrder().getAmount();
map.put("" + this.currentMonth, new Double(value));
}
}
// lookup table row
try
{
int rowNumber = 0;
try
{
rowNumber = ((Integer) GlobalRowOrColumnNumber
.getMonthNumberTableRowNumber().get(new Integer(month)))
.intValue();
} catch (NullPointerException nullPointerException)
{
if (this.dateWithinRange(data))
{
Logger.severe(this, "handlePerMonth",
"Date should be in range, but no row found.");
} else
{
// set the scope outside the game
rowNumber = GlobalRowOrColumnNumber.getMonthHeaderValues()
.size() + 10;
}
}
Event event = new Event(
=====================================================================
Found a 29 line (106 tokens) duplication in the following files:
Starting at line 277 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\handlers\CommittedOrderHandler.java
Starting at line 346 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\handlers\ConfirmedProductionHandler.java
value = data.getOrder().getAmount();
map.put("" + this.currentDay, new Double(value));
}
}
// lookup table row
try
{
int rowNumber = 0;
try
{
rowNumber = ((Integer) GlobalRowOrColumnNumber
.getDayNumberTableRowNumber().get(new Integer(day)))
.intValue();
} catch (NullPointerException nullPointerException)
{
if (this.dateWithinRange(data))
{
Logger.severe(this, "handlePerDay",
"Date should be in range, but no row found.");
} else
{
// set the scope outside the game
rowNumber = GlobalRowOrColumnNumber.getDayHeaderValues()
.size() + 10;
}
}
Event event = new Event(
=====================================================================
Found a 55 line (105 tokens) duplication in the following files:
Starting at line 508 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameactors\GameManufacturer.java
Starting at line 292 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameactors\GameMarket.java
return new BoundingBox(1.0, 1.0, 0.0);
}
/**
* @return Returns the smallMapLocation.
*/
public DirectedPoint getSmallMapLocation()
{
return this.smallMapLocation;
}
/**
* @param smallMapLocation The smallMapLocation to set.
*/
public void setSmallMapLocation(final DirectedPoint smallMapLocation)
{
this.smallMapLocation = smallMapLocation;
}
/**
* @see nl.tudelft.simulation.actor.ActorInterface#getName()
*/
public String getName()
{
return this.name;
}
/**
* @return Returns the animation
*/
protected GisActorAnimation getAnimation()
{
return this.animation;
}
/**
* @see nl.tudelft.simulation.supplychain.actor.SupplyChainActor#calculateDistance(nl.tudelft.simulation.supplychain.actor.SupplyChainActor)
*/
public double calculateDistance(final SupplyChainActor actor)
{
return new CalculateLatLonDistance().getDistance(new Point2d(
this.location.x, this.location.y), new Point2d(actor
.getLocation().x, actor.getLocation().y));
}
/**
* Method changeDemand changes the demand of a PCMarket for the specified
* product.
*
* @param product the product to change the demand for
* @param up if true, demand will increase, if false, the demand will
* decrease
* @param percentage the percentage to change the demand with
*/
public void changeDemand(final Product product, final boolean up,
=====================================================================
Found a 44 line (104 tokens) duplication in the following files:
Starting at line 508 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameactors\GameManufacturer.java
Starting at line 278 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameactors\GameSupplier.java
return new BoundingBox(1.0, 1.0, 0.0);
}
/**
* @return Returns the smallMapLocation.
*/
public DirectedPoint getSmallMapLocation()
{
return this.smallMapLocation;
}
/**
* @param smallMapLocation The smallMapLocation to set.
*/
public void setSmallMapLocation(final DirectedPoint smallMapLocation)
{
this.smallMapLocation = smallMapLocation;
}
/**
* @see nl.tudelft.simulation.actor.ActorInterface#getName()
*/
public String getName()
{
return this.name;
}
/**
* @return Returns the animation
*/
protected GisActorAnimation getAnimation()
{
return this.animation;
}
/**
* @see nl.tudelft.simulation.supplychain.actor.SupplyChainActor#calculateDistance(nl.tudelft.simulation.supplychain.actor.SupplyChainActor)
*/
public double calculateDistance(final SupplyChainActor actor)
{
return new CalculateLatLonDistance().getDistance(new Point2d(
this.location.x, this.location.y), new Point2d(actor
.getLocation().x, actor.getLocation().y));
}
=====================================================================
Found a 30 line (104 tokens) duplication in the following files:
Starting at line 74 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameleader\animation2D\DistributedGisLegendRenderable.java
Starting at line 79 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameleader\animation2D\GisLegendRenderable.java
}
/**
* @see nl.tudelft.simulation.dsol.animation.D2.Renderable2DInterface#paint(java.awt.Graphics2D,
* java.awt.geom.Rectangle2D, java.awt.Dimension,
* java.awt.image.ImageObserver)
*/
public synchronized void paint(final Graphics2D graphics,
final Rectangle2D rectangle, final Dimension dimension,
final ImageObserver observer)
{
GridPanel animationPanel = (GridPanel) observer;
double scale = Renderable2DInterface.Util.getScale(animationPanel
.getExtent(), animationPanel.getSize());
// System.out.println("Scale: " + scale);
Point2d screenLocation = null;
try
{
screenLocation = new Point2d(super.locatable.getLocation().x,
super.locatable.getLocation().y);
} catch (RemoteException remoteException)
{
Logger.severe(this, "paint", remoteException);
}
// we only draw our images if there is a certain zoom level
if (scale >= 0.05063)
=====================================================================
Found a 17 line (103 tokens) duplication in the following files:
Starting at line 348 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\interactionlayer\economics\EconomicsFinancial.java
Starting at line 411 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\interactionlayer\economics\EconomicsFinancial.java
Starting at line 474 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\interactionlayer\economics\EconomicsFinancial.java
if (((String) this.monthHeaderValues.get(i)).equalsIgnoreCase(""))
{
dataList.add(new EconomicsData(i, "", new String[]{"" + "",
"" + "", "" + ""}));
} else
{
dataList.add(new EconomicsData(i, "", new String[]{"" + 0.0,
"" + 0.0, "" + Math.round(this.currentBalance)}));
}
}
if (announce)
{
try
{
this.interactionLayer.notifyAnnounced(new Event(
EconomicsFinancial.UPDATE_ECONOMICS_COLUMNS_MONTH,
=====================================================================
Found a 24 line (102 tokens) duplication in the following files:
Starting at line 378 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameactors\GameDistributor.java
Starting at line 309 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameactors\GameDistributorInteractive.java
}
/**
* @see org.gscg.gameactors.GameDistributor#addDevices()
*/
protected void addDevices()
{
try
{
StreamInterface stream = this.simulator.getReplication().getStream(
"default");
double hour = TimeUnit.convert(1.0, TimeUnitInterface.HOUR,
this.simulator);
DistContinuous hourDist = new DistConstant(stream, hour);
// give the actor a fax device which is checked every hour
FaxDevice fax = new FaxDevice("GameDistributorFax", this.simulator);
addSendingDevice(fax);
MessageHandlerInterface secretary = new HandleAllMessages(this);
addReceivingDevice(fax, secretary, hourDist);
} catch (RemoteException remoteException)
{
Logger.severe(this, "addDevices", remoteException);
}
}
=====================================================================
Found a 24 line (102 tokens) duplication in the following files:
Starting at line 586 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameactors\GameManufacturer.java
Starting at line 310 of D:\java\gaming\supplychain-game\src\java\org\gscg\gameactors\GameManufacturerInteractive.java
}
/**
* @see org.gscg.gameactors.GameManufacturer#addDevices()
*/
protected void addDevices()
{
try
{
StreamInterface stream = this.simulator.getReplication().getStream(
"default");
double hour = TimeUnit.convert(1.0, TimeUnitInterface.HOUR,
this.simulator);
DistContinuous hourDist = new DistConstant(stream, hour);
// give the actor a fax device which is checked every hour
FaxDevice fax = new FaxDevice("GameManufacturerFax", this.simulator);
addSendingDevice(fax);
MessageHandlerInterface secretary = new HandleAllMessages(this);
addReceivingDevice(fax, secretary, hourDist);
} catch (RemoteException remoteException)
{
Logger.severe(this, "addDevices", remoteException);
}
}
=====================================================================
Found a 22 line (100 tokens) duplication in the following files:
Starting at line 130 of D:\java\gaming\supplychain-game\src\java\org\gscg\common\gui\components\AmountSpinnerPanel.java
Starting at line 105 of D:\java\gaming\supplychain-game\src\java\org\gscg\common\gui\components\EstimatedTransportTimePanel.java
final double maximum, final int stepsize, final int initialvalue)
{
super();
try
{
this.minimum = minimum;
this.maximum = maximum;
this.stepSize = stepsize;
this.initialvalue = initialvalue;
double[][] layout = {{250}, {20}};
this.setLayout(new TableLayout(layout));
this.setOpaque(false);
JPanel amountParametersPanel = new JPanel();
amountParametersPanel.setLayout(new BoxLayout(
amountParametersPanel, BoxLayout.X_AXIS));
amountParametersPanel.setOpaque(false);
this.add(amountParametersPanel, "0,0,L,C");
String[] labels = {"Day(s):"};
=====================================================================
Found a 48 line (100 tokens) duplication in the following files:
Starting at line 60 of D:\java\gaming\supplychain-game\src\java\org\gscg\experiment\DistTriangularDiscrete.java
Starting at line 61 of D:\java\gaming\supplychain-game\src\java\org\gscg\experiment\DistTriangularGetters.java
public DistTriangularGetters(final StreamInterface stream, final double a,
final double b, final double c)
{
super(stream, a, b, c);
this.stream = stream;
this.a = a;
this.b = b;
this.c = c;
}
/**
* @return Returns the a.
*/
public double getA()
{
return this.a;
}
/**
* @return Returns the b.
*/
public double getB()
{
return this.b;
}
/**
* @return Returns c.
*/
public double getC()
{
return this.c;
}
/**
* @return Returns the stream.
*/
public StreamInterface getStream()
{
return this.stream;
}
/**
* @see nl.tudelft.simulation.jstats.distributions.DistTriangular#draw()
*/
public double draw()
{
return super.draw();
=====================================================================
Found a 27 line (100 tokens) duplication in the following files:
Starting at line 354 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\handlers\CommittedOrderHandler.java
Starting at line 428 of D:\java\gaming\supplychain-game\src\java\org\gscg\singleuser\handlers\ConfirmedProductionHandler.java
value = data.getOrder().getAmount();
map.put("" + this.currentWeek, new Double(value));
}
}
// lookup table row
try
{
int rowNumber = 0;
try
{
rowNumber = ((Integer) GlobalRowOrColumnNumber
.getWeekNumberTableRowNumber().get(new Integer(week)))
.intValue();
} catch (NullPointerException nullPointerException)
{
if (this.dateWithinRange(data))
{
Logger.severe(this, "handlePerWeek",
"Date should be in range, but no row found.");
} else
{
// set the scope outside the game
rowNumber = GlobalRowOrColumnNumber.getWeekHeaderValues()
.size() + 10;
}
}