activiti 5.17 流程圖中文亂碼問題

1. 流程圖中任務中的中文亂碼顯示問題。spring

 
解決方法:設置processEngineConfiguration中的兩個字體屬性,例如:
<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
     。。。
     <!-- 生成流程圖的字體 -->

     <property name="activityFontName" value="宋體"/>
     <property name="labelFontName" value="宋體"/>字體

</bean>
 
2. 流程圖中TextAnnotation中的中文亂碼顯示問題。
 
此亂碼產生的緣由是,負責畫流程圖的類DefaultProcessDiagramCanvas 定義註解的字體了屬性(爲Arial):
protected static Font ANNOTATION_FONT = new Font("Arial", Font.PLAIN, FONT_SIZE);
而後再畫流程圖時,不知什麼緣由,在外部配置了的字體並無使用,在代碼中硬編碼設置textAnnotation 字體爲ANNOTATION_FONT ,致使出現中文亂碼,外部配置也沒用。見下面代碼:
       public void drawTextAnnotation(String text, GraphicInfo graphicInfo) {
         int x = (int) graphicInfo.getX();
         int y = (int) graphicInfo.getY();
         int width = (int) graphicInfo.getWidth();
         int height = (int) graphicInfo.getHeight();
    
        Font originalFont = g.getFont();
       Stroke originalStroke = g.getStroke();
       
        g.setFont(ANNOTATION_FONT);

       ...
解決方法:從新編譯此模塊,將默認字體改爲宋體,或者註釋掉設置字體代碼。是否能夠自定義DefaultProcessDiagramCanvas,經過擴展的方式來解決,目前我沒有發現。
相關文章
相關標籤/搜索