⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 guigeneral.java

📁 Java编写的蓝牙手机遥控器
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    public MyTitleCanvas()
    {
      this.this$0 = paramGUIGeneral;
      this.DIRECTION_UP = 0;
      this.DIRECTION_DOWN = 2;
      this.leftMargin = 0;
      this.imageEndHight = 0;
      this.imageY = 0;
      this.imageX = 0;
      this.sTemp = new String[1];
      if (!(isDoubleBuffered()))
        this.offscreen = Image.createImage(getWidth(), getHeight());
      this.backGroundColor = 16777215;
      this.foreGroundColor = 0;
      this.textStore = new Vector();
      this.textPos = 0;
      this.firstTime = true;
      this.title = "";
      this.title = "";
      this.subTitle = "";
      this.time = "";
      setFullScreenMode(true);
      this.image = false;
      this.scrollTimerAlive = false;
      this.scrollTimerTask = new GUIGeneral.MyTitleCanvas.ScrollTimerTask(this);
      this.scrollTimer = new Timer();
      this.scrollTimer.schedule(this.scrollTimerTask, 200L, 200L);
    }

    private void startTimer()
    {
      this.scrollTimerAlive = true;
    }

    private void stopTimer()
    {
      this.scrollTimerAlive = false;
    }

    private int getFontInScreenWith()
    {
      Font localFont = Font.getFont(0, 0, 0);
      String str = "A";
      int j = 1;
      BluetoothRemoteControl.debug("getFontInScreenWith");
      while (localFont.stringWidth(str) < paramInt)
      {
        str = str.concat("a");
        ++j;
      }
      return (j + 2);
    }

    public void setText(, String paramString2, String[] paramArrayOfString, int paramInt, boolean paramBoolean, String paramString3)
    {
      if (!(paramBoolean))
        this.image = false;
      if (!(paramString1.equals(this.title)))
      {
        stopTimer();
        this.textPos = 0;
      }
      this.title = paramString1;
      this.subTitle = paramString2;
      this.time = paramString3;
      this.textStore.removeAllElements();
      String str = " ";
      if (this.firstTime)
      {
        this.maxScreenWidth = GUIGeneral.access$600(this.this$0).maxScreenX;
        this.minCharacters = getFontInScreenWith(this.maxScreenWidth);
        this.firstTime = false;
        BluetoothRemoteControl.debug("minCharacters: " + Integer.toString(this.minCharacters));
      }
      int j = 0;
      do
      {
        if (paramInt <= 0)
          return;
        paramArrayOfString[j] = paramArrayOfString[j].trim();
        if (paramArrayOfString[j].length() <= this.minCharacters)
        {
          this.textStore.addElement(paramArrayOfString[j]);
          ++j;
        }
        else
        {
          this.tempString = "";
          this.charToRemove = this.minCharacters;
          this.tempString = paramArrayOfString[j].substring(0, this.minCharacters).trim();
          this.index = this.tempString.indexOf((byte)str.charAt(0));
          if (this.index != -1)
          {
            this.index = this.tempString.lastIndexOf((byte)str.charAt(0));
            BluetoothRemoteControl.debug("SpaceIndex: " + Integer.toString(this.index));
            this.tempString = this.tempString.substring(0, this.index + 1).trim();
            this.charToRemove = (this.index + 1);
          }
          this.textStore.addElement(this.tempString.trim());
          paramArrayOfString[j] = paramArrayOfString[j].substring(this.charToRemove);
        }
      }
      while (j != paramInt);
    }

    public void setImage(, byte[] paramArrayOfByte, int paramInt1, int paramInt2, int paramInt3, int paramInt4)
    {
      if (paramBoolean)
        this.canvasImage = Image.createImage(paramArrayOfByte, paramInt1, paramInt2);
      else
        this.canvasImage = null;
      this.imageX = paramInt3;
      this.imageY = paramInt4;
      this.image = true;
    }

    public void setColor(, int paramInt2, int paramInt3)
    {
      this.backGroundColor = paramInt1;
      this.foreGroundColor = paramInt2;
      this.borderColor = paramInt3;
      if (this.backGroundColor == this.borderColor)
        this.borderColor = this.foreGroundColor;
      if (this.backGroundColor == this.foreGroundColor)
      {
        this.backGroundColor = 16777215;
        this.foreGroundColor = 0;
        this.borderColor = 0;
      }
    }

    private void addOptions(, boolean paramBoolean1, boolean paramBoolean2)
    {
      this.w = paramGraphics.getClipWidth();
      this.h = paramGraphics.getClipHeight();
      this.font = Font.getFont(0, 0, 8);
      paramGraphics.setFont(this.font);
      this.fontHeight = this.font.getHeight();
      this.fontWidth = this.font.stringWidth("Back");
      this.boxHight = (this.fontHeight + 4);
      paramGraphics.setColor(this.borderColor);
      paramGraphics.fillRect(0, this.h - this.boxHight, this.w, this.boxHight);
      paramGraphics.setColor(this.backGroundColor);
      paramGraphics.drawString("OK", 2, this.h - (this.boxHight - this.fontHeight) / 2, 36);
      paramGraphics.drawString("BACK", this.w - 2, this.h - (this.boxHight - this.fontHeight) / 2, 40);
      if (paramBoolean1)
        paramGraphics.fillTriangle(this.w / 2, this.h - this.boxHight + 3, this.w / 2 - 4, this.h - this.boxHight + 3 + 4, this.w / 2 + 4, this.h - this.boxHight + 3 + 4);
      if (paramBoolean2)
        paramGraphics.fillTriangle(this.w / 2, this.h - 2, this.w / 2 - 4, this.h - 2 - 4, this.w / 2 + 4, this.h - 2 - 4);
    }

    public void commandAction(, Displayable paramDisplayable)
    {
    }

    protected void hideNotify()
    {
      stopTimer();
      this.textPos = 0;
    }

    protected void keyPressed()
    {
      BluetoothRemoteControl.debug("keyPressed " + String.valueOf(paramInt));
      int j = getGameAction(paramInt);
      boolean bool = false;
      if (paramInt <= 0);
      switch (j)
      {
      case 1:
        if (this.textPos > 0)
        {
          this.textPos -= 1;
          repaint();
        }
        this.scrolldirection = 0;
        startTimer();
        return;
      case 6:
        if (this.textPos < this.textStore.size() - 3)
        {
          this.textPos += 1;
          repaint();
        }
        else
        {
          this.textPos = 0;
          repaint();
        }
        this.scrolldirection = 2;
        startTimer();
        break;
      default:
        if (this.enableKeyEvent)
        {
          bool = GUIGeneral.access$500(this.this$0, paramInt, 4, j);
          break label188:
          if (this.enableKeyEvent)
            bool = GUIGeneral.access$500(this.this$0, paramInt, 4, j);
        }
      }
      if (!(bool))
      {
        if (GUIGeneral.access$600(this.this$0).rightSoftKey(paramInt))
        {
          label188: GUIGeneral.access$600(this.this$0).sendBack();
          return;
        }
        if (GUIGeneral.access$600(this.this$0).leftSoftKey(paramInt))
        {
          GUIGeneral.access$600(this.this$0).sendOK();
          return;
        }
      }
    }

    protected void keyReleased()
    {
      BluetoothRemoteControl.debug("keyReleased " + String.valueOf(paramInt));
      if (this.enableKeyEvent)
      {
        int j = getGameAction(paramInt);
        if (paramInt <= 0);
        switch (j)
        {
        case 1:
          break;
        case 6:
          break;
        default:
          GUIGeneral.access$500(this.this$0, paramInt, 5, j);
          break label99:
          GUIGeneral.access$500(this.this$0, paramInt, 5, j);
        }
      }
      label99: stopTimer();
    }

    public void show()
    {
      this.enableKeyEvent = paramBoolean;
      Display.getDisplay(GUIGeneral.access$700(this.this$0)).setCurrent(this);
      repaint();
    }

    public void paint()
    {
      try
      {
        Graphics localGraphics = (this.offscreen == null) ? paramGraphics : this.offscreen.getGraphics();
        this.x = localGraphics.getClipX();
        this.y = localGraphics.getClipY();
        this.w = localGraphics.getClipWidth();
        this.h = localGraphics.getClipHeight();
        localGraphics.setColor(this.backGroundColor);
        localGraphics.fillRect(this.x, this.y, this.w, this.h);
        this.font = Font.getFont(0, 0, 0);
        this.fontHeight = this.font.getHeight();
        this.height = (this.fontHeight + 4);
        if ((this.subTitle != null) && (this.subTitle.length() > 0) && (this.subTitle != null))
        {
          this.sTemp[0] = this.subTitle;
          GUIGeneral.access$800(this.this$0, this.sTemp, 0, false);
          GUIGeneral.access$900(this.this$0, this.sTemp, 0);
          this.font = Font.getFont(0, GUIGeneral.access$1700(this.this$0), GUIGeneral.access$1800(this.this$0));
          this.fontHeight = this.font.getHeight();
          localGraphics.setFont(this.font);
          localGraphics.setColor(this.foreGroundColor);
          if (this.image)
          {
            localGraphics.drawString(this.subTitle, 2, this.height, 36);
          }
          else
          {
            this.fontWidth = this.font.stringWidth(this.subTitle);
            if (this.fontWidth < this.w)
              localGraphics.drawString(this.subTitle, (this.w - this.fontWidth) / 2, this.height, 36);
            else
              localGraphics.drawString(this.subTitle, 2, this.height, 36);
          }
        }
        if (this.image)
        {
          this.font = Font.getFont(0, 0, 8);
          this.height += this.font.getHeight() / 2;
          localGraphics.setColor(this.backGroundColor);
          BluetoothRemoteControl.debug(Integer.toString(this.imageX));
          BluetoothRemoteControl.debug(Integer.toString(this.imageY));
          if (this.canvasImage == null)
          {
            localGraphics.fillRect(2, this.height, this.imageX + 2, this.imageY + 2);
          }
          else
          {
            localGraphics.setColor(this.foreGroundColor);
            localGraphics.fillRect(2, this.height, this.imageX + 2, this.imageY + 2);
            localGraphics.drawImage(this.canvasImage, 3, this.height + 1, 20);
          }
          this.leftMargin = (this.imageX + 2 + 2 + this.font.getHeight() / 2);
          this.imageEndHight = (this.imageY + this.height + 2 + 2);
        }
        if ((this.title != null) && (this.title.length() > 0) && (this.title != null))
        {
          this.sTemp[0] = this.title;
          GUIGeneral.access$800(this.this$0, this.sTemp, 0, true);
          GUIGeneral.access$900(this.this$0, this.sTemp, 0);
          this.font = Font.getFont(0, GUIGeneral.access$1700(this.this$0), GUIGeneral.access$1800(this.this$0));
          this.fontHeight = this.font.getHeight();
          localGraphics.setFont(this.font);
          localGraphics.setColor(this.foreGroundColor);
          this.height += this.fontHeight;
          if (this.image)
          {
            localGraphics.drawString(this.title, this.leftMargin, this.height, 36);
          }
          else
          {
            this.fontWidth = this.font.stringWidth(this.title);
            if (this.fontWidth < this.w)
              localGraphics.drawString(this.title, (this.w - this.fontWidth) / 2, this.height, 36);
            else
              localGraphics.drawString(this.title, 2, this.height, 36);
          }
        }
        if ((this.time != null) && (this.time.length() > 0) && (this.time != null))
        {
          this.font = Font.getFont(0, 0, 0);
          this.fontHeight = this.font.getHeight();
          localGraphics.setFont(this.font);
          this.height = (this.height + this.fontHeight + 4);
          localGraphics.drawString(this.time, this.leftMargin, this.height, 36);
        }
        if (this.image)
          this.height = this.imageEndHight;
        this.font = Font.getFont(0, 0, 0);
        this.fontHeight = this.font.getHeight();
        localGraphics.setFont(this.font);
        localGraphics.setColor(this.foreGroundColor);
        this.up = false;
        this.down = false;
        if ((this.title.length() > 0) && (!(this.image)) && (this.time.length() == 0) && (this.subTitle.length() == 0))
        {
          this.font = Font.getFont(0, 0, 8);
          this.fontHeight = this.font.getHeight();
          this.height += this.fontHeight / 2;
        }
        this.i = 0;
        while (this.i < this.textStore.size() - this.textPos)
        {
          this.height += this.fontHeight;
          this.fontWidth = this.font.stringWidth((String)this.textStore.elementAt(this.textPos + this.i));
          localGraphics.drawString((String)this.textStore.elementAt(this.textPos + this.i), 2, this.height, 36);
          if (this.height >= this.h)
          {
            this.down = true;
            break;
          }
          this.i += 1;
        }
        if (this.textPos > 0)
          this.up = true;
        addOptions(localGraphics, this.up, this.down);
        if (this.offscreen != null)
          paramGraphics.drawImage(this.offscreen, 0, 0, 24);
      }
      catch (Exception localException)
      {
      }
    }

    static boolean access$1900(MyTitleCanvas paramMyTitleCanvas)
    {
      return paramMyTitleCanvas.scrollTimerAlive;
    }

    static int access$2000(MyTitleCanvas paramMyTitleCanvas)
    {
      return paramMyTitleCanvas.scrolldirection;
    }

    static int access$2100(MyTitleCanvas paramMyTitleCanvas)
    {
      return paramMyTitleCanvas.textPos;
    }

    static int access$2110(MyTitleCanvas paramMyTitleCanvas)
    {
      return (paramMyTitleCanvas.textPos--);
    }

    static Vector access$2200(MyTitleCanvas paramMyTitleCanvas)
    {
      return paramMyTitleCanvas.textStore;
    }

    static int access$2108(MyTitleCanvas paramMyTitleCanvas)
    {
      return (paramMyTitleCanvas.textPos++);
    }

    static int access$2102(MyTitleCanvas paramMyTitleCanvas)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -