コード例 #1
0
ファイル: Usr.java プロジェクト: qoopooh/try_git
  /** @return Generated byte array for setting USR module */
  private byte[] getBytes() {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    byte[] mac = BinaryConversion.hexStringToByteArray(mMac);
    byte[] destIp = BinaryConversion.ipToByteArray(mDestIp);
    byte[] destPort = BinaryConversion.intToByteArray(mDestPort, 2);
    byte[] hostIp = BinaryConversion.ipToByteArray(mHostIp);
    byte[] hostPort = BinaryConversion.intToByteArray(mHostPort, 2);
    byte[] gatewayIp = BinaryConversion.ipToByteArray(mGatewayIp);
    byte[] baud = BinaryConversion.intToByteArray(mBaud, 3);

    try {
      baos.write(mac);
      baos.write(SETTING_MSG.getBytes());
      baos.write(destIp);
      baos.write(destPort);
      baos.write(hostIp);
      baos.write(hostPort);
      baos.write(gatewayIp);
      baos.write((byte) mMode.ordinal());
      baos.write(baud);
      baos.write(SETTING_MSG.getBytes());
    } catch (IOException e) {
      e.printStackTrace();
    }

    return baos.toByteArray();
  }
コード例 #2
0
  @Override
  public void writeToNBT(NBTTagCompound nbt, MappingRegistry registry) {
    nbt.setByte("mode", (byte) mode.ordinal());
    nbt.setInteger("x", x);
    nbt.setInteger("y", y);
    nbt.setInteger("z", z);

    if (schematic != null) {
      NBTTagCompound schematicNBT = new NBTTagCompound();
      SchematicFactory.getFactory(schematic.getClass())
          .saveSchematicToWorldNBT(schematicNBT, schematic, registry);
      nbt.setTag("schematic", schematicNBT);
    }

    NBTTagList nbtStacks = new NBTTagList();

    if (stackConsumed != null) {
      for (ItemStack stack : stackConsumed) {
        NBTTagCompound nbtStack = new NBTTagCompound();
        stack.writeToNBT(nbtStack);
        nbtStacks.appendTag(nbtStack);
      }
    }

    nbt.setTag("stackConsumed", nbtStacks);
  }
コード例 #3
0
 @Override
 public void display(GLAutoDrawable drawable) {
   final GL3bc gl = drawable.getGL().getGL3bc();
   float color = ((float) currentMode.ordinal() + 1) / (Mode.values().length + 2);
   gl.glClearColor(color, color, color, 0);
   gl.glClear(GL3.GL_COLOR_BUFFER_BIT | GL3.GL_DEPTH_BUFFER_BIT);
   gl.glUseProgram(progID);
   final Mode newMode;
   {
     currentModeIdx = (currentModeIdx + 1) % allModes.length;
     newMode = allModes[currentModeIdx];
   }
   if (newMode != currentMode) {
     currentMode = newMode;
     System.out.println("Display mode: " + currentMode);
   }
   currentMode.display(this, gl);
   gl.glUseProgram(0);
 }
コード例 #4
0
ファイル: ButtonToolBar.java プロジェクト: yegor86/whiteboard
 /** @return получить режи рисовоания */
 public int getMode() {
   return mode.ordinal();
 }