Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.4
    • Fix Version/s: 1.5.2, 2.0
    • Component/s: demos
    • Labels:
      None
    • Environment:
      Firefox 3.6,java 1.6_18,windows xp

      Description

      please see attached image file. it's an i18n issue.

        Issue Links

          Activity

          Hide
          Greg Brown added a comment -

          This should now be resolved in both 1.5.x and trunk. Please re-open if you see any issues with the fix.

          Show
          Greg Brown added a comment - This should now be resolved in both 1.5.x and trunk. Please re-open if you see any issues with the fix.
          Hide
          Alex XIAO added a comment -

          Thank you very much! You solved my problem.

          And I think the following codes is also important:

          //look at here, use these codes to set week label values.
          2. if (Locale.getDefault().equals(Locale.CHINA)

          Locale.getDefault().equals(Locale.CHINESE)) { text = Character.toString(text.charAt(2)); }

          else

          { text = Character.toString(text.charAt(0)); }

          Because Chinese Week Names are like "星期一,星期二",
          So we should use text = Character.toString(text.charAt(2)) instead.

          Thank you for your hard work.
          I love Pivot.

          Best Regards,
          Alex XIAO

          Show
          Alex XIAO added a comment - Thank you very much! You solved my problem. And I think the following codes is also important: //look at here, use these codes to set week label values. 2. if (Locale.getDefault().equals(Locale.CHINA) Locale.getDefault().equals(Locale.CHINESE)) { text = Character.toString(text.charAt(2)); } else { text = Character.toString(text.charAt(0)); } Because Chinese Week Names are like "星期一,星期二", So we should use text = Character.toString(text.charAt(2)) instead. Thank you for your hard work. I love Pivot. Best Regards, Alex XIAO
          Hide
          Greg Brown added a comment -

          Can you try replacing TerraCalendarSkin#setFont(Font) with this:

          public void setFont(Font font) {
          if (font == null)

          { throw new IllegalArgumentException("font is null."); }

          this.font = font;

          monthSpinner.getStyles().put("font", font);
          yearSpinner.getStyles().put("font", font);

          TablePane.Row row = calendarTablePane.getRows().get(1);
          for (int i = 0; i < 7; i++)

          { Label label = (Label)row.get(i); label.getStyles().put("font", font); }

          invalidateComponent();
          }

          You should then be able to set the font style of your Calendar. Let me know if this works.

          However, if you set the theme font (via Theme#setFont()) before you create any components, you shouldn't need to set the font explicitly for any single component. Have you tried that?

          Show
          Greg Brown added a comment - Can you try replacing TerraCalendarSkin#setFont(Font) with this: public void setFont(Font font) { if (font == null) { throw new IllegalArgumentException("font is null."); } this.font = font; monthSpinner.getStyles().put("font", font); yearSpinner.getStyles().put("font", font); TablePane.Row row = calendarTablePane.getRows().get(1); for (int i = 0; i < 7; i++) { Label label = (Label)row.get(i); label.getStyles().put("font", font); } invalidateComponent(); } You should then be able to set the font style of your Calendar. Let me know if this works. However, if you set the theme font (via Theme#setFont()) before you create any components, you shouldn't need to set the font explicitly for any single component. Have you tried that?
          Hide
          Alex XIAO added a comment -

          BTY, I use Apache Pivot version 1.5.
          Java 1.6.0_21

          Show
          Alex XIAO added a comment - BTY, I use Apache Pivot version 1.5. Java 1.6.0_21
          Hide
          Alex XIAO added a comment -

          I think TerraCalendarSkin.java has font issue:
          when I use following code, I found only the Day table's font changes. but the spinners for Month and Year are not.
          <Calendar styles="

          {font:'Courier New 24'}

          "/>

          I changed TerraCalendarSkin class's updateLabels method as following:

          private void updateLabels() {
          TablePane.Row row = calendarTablePane.getRows().get(1);

          Calendar calendar = (Calendar) getComponent();
          Locale locale = calendar.getLocale();
          GregorianCalendar gregorianCalendar = new GregorianCalendar(locale);
          SimpleDateFormat monthFormat = new SimpleDateFormat("E", locale);
          int firstDayOfWeek = gregorianCalendar.getFirstDayOfWeek();

          for (int i = 0; i < 7; i++) {
          Label label = (Label) row.get;
          //look at here.........
          1. label.getStyles.put("font", new Font("simsun",Font.Bold, 24);
          //end.
          gregorianCalendar.set(java.util.Calendar.DAY_OF_WEEK,
          firstDayOfWeek + i);
          String text = monthFormat.format(gregorianCalendar.getTime());

          //look at here.................
          2. if (Locale.getDefault().equals(Locale.CHINA)

          Locale.getDefault().equals(Locale.CHINESE)) { text = Character.toString(text.charAt(2)); }

          else

          { text = Character.toString(text.charAt(0)); }

          // end
          label.setText(text);
          }
          }

          see 1 & 2.

          When I modified this method. the Week labels can show Chinese font correctly.

          Show
          Alex XIAO added a comment - I think TerraCalendarSkin.java has font issue: when I use following code, I found only the Day table's font changes. but the spinners for Month and Year are not. <Calendar styles=" {font:'Courier New 24'} "/> I changed TerraCalendarSkin class's updateLabels method as following: private void updateLabels() { TablePane.Row row = calendarTablePane.getRows().get(1); Calendar calendar = (Calendar) getComponent(); Locale locale = calendar.getLocale(); GregorianCalendar gregorianCalendar = new GregorianCalendar(locale); SimpleDateFormat monthFormat = new SimpleDateFormat("E", locale); int firstDayOfWeek = gregorianCalendar.getFirstDayOfWeek(); for (int i = 0; i < 7; i++) { Label label = (Label) row.get ; //look at here......... 1. label.getStyles.put("font", new Font("simsun",Font.Bold, 24); //end. gregorianCalendar.set(java.util.Calendar.DAY_OF_WEEK, firstDayOfWeek + i); String text = monthFormat.format(gregorianCalendar.getTime()); //look at here................. 2. if (Locale.getDefault().equals(Locale.CHINA) Locale.getDefault().equals(Locale.CHINESE)) { text = Character.toString(text.charAt(2)); } else { text = Character.toString(text.charAt(0)); } // end label.setText(text); } } see 1 & 2. When I modified this method. the Week labels can show Chinese font correctly.
          Hide
          Greg Brown added a comment -

          You don't have to replace the scheme file from the JAR. You can specify a custom scheme using the "org.apache.pivot.wtk.skin.terra.location" system property. The value is the path to the scheme's JSON descriptor file on the classpath.

          TerraCalendarSkin does support a font property. I can't test "simsun" because I don't have it on my system, but the following works for me:

          <Calendar styles="

          {font:'Courier New 14'}

          "/>

          Show
          Greg Brown added a comment - You don't have to replace the scheme file from the JAR. You can specify a custom scheme using the "org.apache.pivot.wtk.skin.terra.location" system property. The value is the path to the scheme's JSON descriptor file on the classpath. TerraCalendarSkin does support a font property. I can't test "simsun" because I don't have it on my system, but the following works for me: <Calendar styles=" {font:'Courier New 14'} "/>
          Hide
          Alex XIAO added a comment -

          I found a way to replace the font setting.
          open and edit this file org\apache\pivot\wtk\skin\terra\TerraTheme_default.json

          1. set the font property to "Monospaced 12" or "simsun 12".
          2. rebuild the jar file.

          but I think this is ugly.

          And I think Calendar should support "font" property in "Styles" map.

          Show
          Alex XIAO added a comment - I found a way to replace the font setting. open and edit this file org\apache\pivot\wtk\skin\terra\TerraTheme_default.json 1. set the font property to "Monospaced 12" or "simsun 12". 2. rebuild the jar file. but I think this is ugly. And I think Calendar should support "font" property in "Styles" map.
          Hide
          Alex XIAO added a comment -

          may be other "Component" take effect. but "Calender" not.

          my code is:
          //no effect.
          calendar.getStyles().put("font",new Font("simsun",Font.PLAIN,12)); //Calendar instance.

          selectedDateLabel.getStyles().put("font",new Font("simsun",Font.PLAIN,12)); //Label instance.

          Is there some document for setting "Styles"?

          Show
          Alex XIAO added a comment - may be other "Component" take effect. but "Calender" not. my code is: //no effect. calendar.getStyles().put("font",new Font("simsun",Font.PLAIN,12)); //Calendar instance. selectedDateLabel.getStyles().put("font",new Font("simsun",Font.PLAIN,12)); //Label instance. Is there some document for setting "Styles"?
          Hide
          Greg Brown added a comment -

          Most likely due to the use of the Verdana font in the Component Explorer application - Verdana does not support Chinese characters.

          Show
          Greg Brown added a comment - Most likely due to the use of the Verdana font in the Component Explorer application - Verdana does not support Chinese characters.
          Hide
          Alex XIAO added a comment -

          language: zh_CN

          Show
          Alex XIAO added a comment - language: zh_CN

            People

            • Assignee:
              Greg Brown
              Reporter:
              Alex XIAO
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development