本文整理汇总了Java中net.sf.freecol.client.gui.panel.CargoPanel类的典型用法代码示例。如果您正苦于以下问题:Java CargoPanel类的具体用法?Java CargoPanel怎么用?Java CargoPanel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CargoPanel类属于net.sf.freecol.client.gui.panel包,在下文中一共展示了CargoPanel类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addCargo
import net.sf.freecol.client.gui.panel.CargoPanel; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public Component addCargo(Component comp, Unit carrier, CargoPanel cargoPanel) {
MarketLabel label = (MarketLabel) comp;
Player player = carrier.getOwner();
if (!player.canTrade(label.getType())) {
cargoPanel.igc().payArrears(label.getType());
return null;
}
int loadable = carrier.getLoadableAmount(label.getType());
if (loadable <= 0) return null;
if (loadable > label.getAmount()) loadable = label.getAmount();
cargoPanel.igc().buyGoods(label.getType(), loadable, carrier);
cargoPanel.igc().nextModelMessage();
cargoPanel.update();
return comp;
}
示例2: addCargo
import net.sf.freecol.client.gui.panel.CargoPanel; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public Component addCargo(Component comp, Unit carrier, CargoPanel cargoPanel) {
Goods goods = ((GoodsLabel) comp).getGoods();
int loadable = carrier.getLoadableAmount(goods.getType());
if (loadable <= 0) return null;
if (loadable > goods.getAmount()) loadable = goods.getAmount();
Goods toAdd = new Goods(goods.getGame(), goods.getLocation(),
goods.getType(), loadable);
goods.setAmount(goods.getAmount() - loadable);
cargoPanel.igc().loadCargo(toAdd, carrier);
cargoPanel.update();
return comp;
}
示例3: removeCargo
import net.sf.freecol.client.gui.panel.CargoPanel; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void removeCargo(Component comp, CargoPanel cargoPanel) {
Goods g = ((GoodsLabel) comp).getGoods();
cargoPanel.igc().unloadCargo(g, false);
cargoPanel.update();
}
示例4: addCargo
import net.sf.freecol.client.gui.panel.CargoPanel; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public Component addCargo(Component comp, Unit carrier, CargoPanel cargoPanel) {
Unit unit = ((UnitLabel)comp).getUnit();
if (carrier.canAdd(unit)) {
Container oldParent = comp.getParent();
if (cargoPanel.igc().boardShip(unit, carrier)) {
((UnitLabel) comp).setSmall(false);
if (oldParent != null) oldParent.remove(comp);
cargoPanel.update();
return comp;
}
}
return null;
}
示例5: removeCargo
import net.sf.freecol.client.gui.panel.CargoPanel; //导入依赖的package包/类
@Override
public void removeCargo(Component comp, CargoPanel cargoPanel) {
Unit unit = ((UnitLabel)comp).getUnit();
cargoPanel.igc().leaveShip(unit);
cargoPanel.update();
}
示例6: addCargo
import net.sf.freecol.client.gui.panel.CargoPanel; //导入依赖的package包/类
/**
* The {@code Component} to add to a {@code CargoPanel}.
*
* @param comp The input Component to add.
* @param carrier The Carrier to add the component too.
* @param cargoPanel The CargoPanel to affect.
* @return The output Component to add.
*/
public Component addCargo(Component comp, Unit carrier, CargoPanel cargoPanel);
示例7: removeCargo
import net.sf.freecol.client.gui.panel.CargoPanel; //导入依赖的package包/类
/**
* The {@code Component} to remove from a {@code CargoPanel}.
*
* @param comp The Component to remove.
* @param cargoPanel The {@link CargoPanel} to affect.
*/
public default void removeCargo(Component comp, CargoPanel cargoPanel) {
cargoPanel.update();
}