コード例 #1
0
ファイル: Timer.java プロジェクト: OldDragon2A/Timer
  public Element toXML() {
    Element result = new Element("timer");

    XMLUtil.createElement("title", getTitle(), result);
    XMLUtil.createElement("started", started == null ? "" : started.toString(), result);
    XMLUtil.createElement("total", period.toString(), result);
    XMLUtil.createElement("speed", update_speed, result);

    XMLUtil.createElement("x", getX(), result);
    XMLUtil.createElement("y", getY(), result);
    XMLUtil.createElement("width", getWidth(), result);
    XMLUtil.createElement("height", getHeight(), result);

    XMLUtil.createElement(
        "foreground", String.format("%08x", total.getForeground().getRGB()), result);
    XMLUtil.createElement(
        "background", String.format("%08x", panel.getBackground().getRGB()), result);

    XMLUtil.createElement("visible", isVisible(), result);

    Element times = new Element("times");
    for (TimeSpan ts : this.times) {
      times.addContent(ts.toXML());
    }
    result.addContent(times);
    return result;
  }
コード例 #2
0
ファイル: Timer.java プロジェクト: OldDragon2A/Timer
 protected void actionToggle() {
   if (started == null) {
     miToggle.setText("Stop");
     started = new DateTime();
     timer.start();
   } else {
     miToggle.setText("Start");
     DateTime end = new DateTime();
     TimeSpan ts = new TimeSpan(started, end);
     times.add(ts);
     period = period.plus(ts.getPeriod()).normalizedStandard();
     started = null;
     timer.stop();
     updateTimes();
   }
 }
コード例 #3
0
  @Override
  public void Update(GameTime gameTime) {
    _delayTime = TimeSpan.Add(_delayTime, gameTime.ElapsedGameTime());

    if (_delayTime.miliseconds() <= 100) return;
    _delayTime = TimeSpan.Zero();
    if (_isClicked) {
      _sprites.get(0).Update();

      if (_sprites.get(0).FrameIndex() == 0) {
        Clicked.Add(DoClick.GetInstance(this));
        _isClicked = false;
      }
    }

    super.Update(gameTime);
  }
コード例 #4
0
ファイル: OrgRelation.java プロジェクト: djw1149/cougaar-glm
  public Object clone() {
    OrgRelation or = new OrgRelation(orgID, oplanUID);
    or.setForcePackageId(forcePackageID);
    or.setRelationType(relationType);
    or.setAssignedRole(role);
    or.setOtherOrgId(otherOrgID);
    or.setUID(getUID());
    or.setOwner(getOwner());

    if (timeSpan != null) or.setTimeSpan((TimeSpan) timeSpan.clone());
    return or;
  } // clone
コード例 #5
0
public class Chest extends DrawableGameComponent implements ITappedInner {

  private List<Sprite> _sprites = new ArrayList<Sprite>();
  private String _path;
  private boolean _isClicked;
  private Vector2 _position;
  private TimeSpan _delayTime = TimeSpan.Zero();
  private PanelButton _itemPanel;
  private boolean _isPanelButtonAdded;
  private GameScreen _owner;
  public event Clicked;
  public event ShopOpened;
  public event ShopClosed;
  public event ItemBought;

  public Chest(Game game, GameScreen owner, String fullPath, Vector2 position) {
    super(game);
    _path = fullPath;

    _isClicked = false;

    _position = position;

    _owner = owner;

    Clicked = new event(this);
    ShopOpened = new event(this);
    ShopClosed = new event(this);
    ItemBought = new event(this);

    ShopOpened.Add(ShopOpenProcessing.GetInstance());

    ShopClosed.Add(ShopCloseProcessing.GetInstance());

    ItemBought.Add(ItemBoughtProcessing.GetInstance());

    _isPanelButtonAdded = false;

    Initialize();

    LoadContent();
  }

  public PanelButton ItemPanel() {
    return _itemPanel;
  }

  public void ItemPanel(PanelButton value) {
    _itemPanel = value;
  }

  public boolean IsPanelButtonAdded() {
    return _isPanelButtonAdded;
  }

  public void IsPanelButtonAdded(boolean value) {
    _isPanelButtonAdded = value;
  }

  @Override
  public void Initialize() {
    int id = Factory.getResourceID(_path, ResourceType.xml);
    XmlResourceParser xrp = _game.Resource().getXml(id);
    String tagName = "";
    String value = "";
    int numFrame;
    int frameWidth;
    int frameHeight;
    int xCenterPoint;
    int yCenterPoint;
    int bitmapResID;
    boolean isVertical;
    try {
      while (xrp.getEventType() != XmlResourceParser.END_DOCUMENT) {
        if (xrp.getEventType() == XmlResourceParser.START_TAG) {
          tagName = xrp.getName();

          if (tagName.equals("Definition")) {
            numFrame = xrp.getAttributeIntValue(null, "NumFrame", 0);

            frameWidth = xrp.getAttributeIntValue(null, "FrameWidth", 0);

            frameHeight = xrp.getAttributeIntValue(null, "FrameHeight", 0);

            xCenterPoint = xrp.getAttributeIntValue(null, "XCenterPoint", 0);

            yCenterPoint = xrp.getAttributeIntValue(null, "YCenterPoint", 0);

            bitmapResID = xrp.getAttributeResourceValue(null, "SheetName", 0);

            isVertical = xrp.getAttributeBooleanValue(null, "IsVertical", false);

            Bitmap bmp = BitmapFactory.decodeResource(Game().Resource(), bitmapResID);
            _sprites.add(
                new Sprite(
                    null,
                    bmp,
                    numFrame,
                    new Vector2(frameWidth, frameHeight),
                    new Vector2(xCenterPoint, yCenterPoint),
                    isVertical));
          }
        }

        if (xrp.getEventType() == XmlResourceParser.TEXT) {
          if (tagName.equals("Panel")) {
            value = xrp.getText();
            if (value != "") {
              _itemPanel = new PanelButton(_game, _owner, value);
            }
          }
        }
        xrp.next();
      }
      xrp.close();
    } catch (XmlPullParserException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }

    super.Initialize();
  }

  @Override
  public void LoadContent() {
    for (int i = 0; i < _itemPanel.Grid().get(0).Rows(); i++)
      for (int j = 0; j < _itemPanel.Grid().get(0).Cols(); j++) {
        _itemPanel
            .Grid()
            .get(0)
            .Blanks()[i][j]
            .Clicked
            .Add(PushalbeBlankAdditionFuncEvent.GetInstance(this));
      }
  }

  @Override
  public void Update(GameTime gameTime) {
    _delayTime = TimeSpan.Add(_delayTime, gameTime.ElapsedGameTime());

    if (_delayTime.miliseconds() <= 100) return;
    _delayTime = TimeSpan.Zero();
    if (_isClicked) {
      _sprites.get(0).Update();

      if (_sprites.get(0).FrameIndex() == 0) {
        Clicked.Add(DoClick.GetInstance(this));
        _isClicked = false;
      }
    }

    super.Update(gameTime);
  }

  @Override
  public void Draw(GameTime gameTime) {
    _sprites.get(0).Draw((SpriteBatch) Game().GetService("SpriteBatch"), _position, Color.WHITE);
    Clicked.occur(!_isPanelButtonAdded);
    if (_isPanelButtonAdded) {
      _itemPanel.Draw(gameTime);
    }
    super.Draw(gameTime);
  }

  public boolean CheckTapped(Point p) {
    Rect rect =
        new Rect(
            (int) _position.x,
            (int) _position.y,
            (int) _sprites.get(0).size().x + (int) _position.x,
            (int) _sprites.get(0).size().y + (int) _position.y);

    boolean isTapped = rect.contains(p.x, p.y);
    if (isTapped) {
      _isClicked = true;
    }
    return isTapped;
  }
}
コード例 #6
0
 public static TimeSpan subtract(TimeSpan first, TimeSpan second) {
   return first.subtract(second);
 }
コード例 #7
0
 public static TimeSpan add(TimeSpan first, TimeSpan second) {
   return first.add(second);
 }