2006年3月31日
錯誤信息如下:
java.lang.NoClassDefFoundError: sun.management.ManagementFactory
處理:
把sun.management.ManagementFactory替換成java.lang.management.ManagementFactory
因?yàn)?/span>ibm的jdk沒有sun.management.ManagementFactory這個對象
錯誤信息如下:
超過最大長度限制
處理:
只能插入666個中文字符。
或者更新到最新的oracle驅(qū)動包
1:derby.jar包可能沖突,需刪除項(xiàng)目中的該包
2:MBean調(diào)用問題
Websphere的MBean注冊路徑包括cell,nodeName和processName,具體可以銅鼓jconsole連接來查看MBean注冊的全路徑。這三個值可以通過Websphere的com.ibm.websphere.management.AdminServiceFactory這個對象來獲取,spring中的配置如下:
<!--
用于獲取websphere的MBean名稱的cell,node,process -->
<bean id="adminService" class="com.ibm.websphere.management.AdminServiceFactory" factory-method="getAdminService"/>
<bean id="adminService.cellName" class="org.springframework.beans.factory.config.PropertyPathFactoryBean"/>
<bean id="adminService.nodeName" class="org.springframework.beans.factory.config.PropertyPathFactoryBean"/>
<bean id="adminService.processName" class="org.springframework.beans.factory.config.PropertyPathFactoryBean"/>
<bean id="websphereNamingStrategy" class="com.des.engine.mbean.WebsphereNamingStrategy">
<property name="cellName" ref="adminService.cellName"/>
<property name="nodeName" ref="adminService.nodeName"/>
<property name="processName" ref="adminService.processName"/>
</bean>
WebsphereNamingStrategy為自己創(chuàng)建的對象就包括那三個屬性
3:安全問題
出現(xiàn)如下錯誤,Caused by: javax.management.JMRuntimeException: ADMN0022E: 由于憑證不足或憑證為空,無法對 org.apache.servicemix:Name=ServiceMgtImpl,cell=dvpbNode02Cell,Type=SystemService,ContainerName=ServiceMix,node=dvpbNode02,process=server1 MBean 的 retrieveServiceList 操作進(jìn)行訪問。
該問題是因?yàn)樵O(shè)置了安全控制,把控制臺的【安全性->安全管理、應(yīng)用程序和基礎(chǔ)結(jié)構(gòu)】里面的所以安全配置都去掉,然后重新啟動服務(wù)器主機(jī)(注意是重啟主機(jī),不然安全設(shè)置不起作用),再啟動websphere服務(wù)應(yīng)該就可以了,還有就是servicemix的應(yīng)用要跟websphere一起啟動,不要等websphere啟動后再到控制臺啟動
錯誤信息如下:
jdbc在操作oracle海量數(shù)據(jù)的時候用ResultSet獲取所有的返回數(shù)據(jù)出現(xiàn)內(nèi)存溢出
處理:
出錯的原因是ResultSet用的是可滾動結(jié)果集,正常情況下ResultSet是指針指向數(shù)據(jù)庫的數(shù)據(jù),本身是不存儲數(shù)據(jù)庫的數(shù)據(jù)的,默認(rèn)情況下就算是提交的sql能查詢處上億條的數(shù)據(jù)也是不消耗內(nèi)存的,但是如果用的是可滾動結(jié)果集的ResultSet情況就不一樣了,ORACLE 是不支持可滾動結(jié)果集的,那么我們用JDBC得到一個可滾動的結(jié)果集就是由JDBC自己支持的,也就是說結(jié)果集是要存放在內(nèi)存中的,所以在海量數(shù)據(jù)的情況下也就是要消耗大量內(nèi)存的,因此造成內(nèi)存溢出也就是正常的了,所以如果是海量數(shù)據(jù)的話就不要用可滾動結(jié)果集就可以了。
錯誤信息如下:
com.ibm.websphere.ce.cm.StaleConnectionException: [ibm][db2][jcc][t4][2030][11211]
檢測到了通信錯誤。所使用的通信協(xié)議:TCP/IP。"n所使用的通信 API:SOCKETS。
檢測到錯誤的位置:Reply.fill()。"n用于檢測錯誤的通信功能:InputStream.read()。
特定于協(xié)議的錯誤代碼數(shù)據(jù)不足、* 和 0。消息:null"n
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)"n
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:67)"n at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance
(DelegatingConstructorAccessorImpl.java:45)"n
at java.lang.reflect.Constructor.newInstance(Constructor.java:522)"n
at com.ibm.websphere.rsadapter.GenericDataStoreHelper.mapExceptionHelper
(GenericDataStoreHelper.java:523)"n
at com.ibm.websphere.rsadapter.GenericDataStoreHelper.mapException(GenericDataStoreHelper.java:578)"n
at com.ibm.ws.rsadapter.jdbc.WSJdbcUtil.mapException(WSJdbcUtil.java:909)"n
at com.ibm.ws.rsadapter.jdbc.WSJdbcStatement.executeQuery(WSJdbcStatement.java:898)"n
at com.newland.bi.util.db.DBUtil.executeQuery(Unknown Source)"n
at com.newland.bi.util.db.DBUtil.executeSql(Unknown Source)"n
at com.newland.bi.dao.jdbc.DaoImpl.executeQuery(DaoImpl.java:64)"n
at com.newland.bi.service.report.exp.dao.ReportExpDao.getExpList(ReportExpDao.java:72)"n
at com.newland.bi.service.report.exp.manage.ReportExpMgt.runExport(ReportExpMgt.java:91)"n
at com.newland.bi.service.report.exp.servlet.ReportExp1Servlet$1.run(ReportExp1Servlet.java:97)"n
at java.util.TimerThread.mainLoop(Timer.java:537)"n at java.util.TimerThread.run(Timer.java:487)"n
處理:
出錯的原因可能是防火墻問題,在websphere應(yīng)用服務(wù)器和數(shù)據(jù)庫服務(wù)器之間是否存在防火墻
防火墻是否會設(shè)置多久沒活動的連接就自動斷開掉,如果是這樣的話就會有問題,因?yàn)?/span>websphere上面的數(shù)據(jù)庫連接池可能有一段時間沒連接而被防火墻斷掉了
但對于連接池本身根本就不知道該連接是否還可用,所以web應(yīng)用從連接池獲取的連接可能就是已經(jīng)斷開的了,所以就可能會出現(xiàn)日記中的錯誤問題
schedule和scheduleAtFixedRate的區(qū)別在于,如果指定開始執(zhí)行的時間在當(dāng)前系統(tǒng)運(yùn)行時間之前,scheduleAtFixedRate會把已經(jīng)過去的時間也作為周期執(zhí)行,而schedule不會把過去的時間算上。
錯誤信息如下:
Caused by: java.lang.ClassNotFoundException: org.apache.axis.soap.MessageFactoryImpl
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at javax.xml.soap.MessageFactory.newInstance(MessageFactory.java:50)
... 10 more
處理:
原因是調(diào)用了axis的 soap.MessageFactoryImpl,cxf應(yīng)該用的是sun的
在注冊安全攔截器之前執(zhí)行下面代碼就可以了
System.setProperty("javax.xml.soap.MessageFactory", "com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl");
我們寫程序的時候可能會想用open或者<a>來下載一個txt文件,但我們會發(fā)現(xiàn)我們用瀏覽器下載這個txt文件的時候老是在瀏覽器里面直接打開了,而不是提示下載,這樣的話如果txt文件的內(nèi)容非常多的話肯定是不行的,可能就會導(dǎo)致瀏覽器掛掉,客戶機(jī)器死機(jī)的問題
現(xiàn)整理了個解決辦法,代碼如下:
1.下載頁面
open(action執(zhí)行頁面,'iframeName','');
2.action執(zhí)行頁面
<a id="tempB" style="display:none" href="#" onclick=""> </a>
<iframe width=0 height=0 id="hideIframe" name="hideIframe"></iframe>

<script>
var n=0;

function go(url)
{
n==0?new function()

{
frames("hideIframe").location=url,n=1
}:null;
document.all("hideIframe").readyState!="complete"?setTimeout(go,10):so();
function so()

{
frames("hideIframe").document.execCommand("SaveAs"),n=0
};
}
var tempB = document.getElementById("tempB");
<%

if(path.toLowerCase().indexOf(".txt")>=0)
{
%>

tempB.attachEvent('onclick',function()
{go('<%=request.getContextPath()+"/tempfile/1.txt">');});
<%

}else
{
%>

tempB.attachEvent('onclick',function()
{open('<%=request.getContextPath()+"/tempfile/1.xls">','','');});
<%
}
%>
tempB.click();
</script>
websphere部署war應(yīng)用失敗正常原因是web.xml的節(jié)點(diǎn)定義循序問題,或者一些空格,字符原因造成的
可能先定義完所有的servlet后再定義所有的servlet mapping就沒問題了
那個轉(zhuǎn)向后的頁面已經(jīng)有用gb2312的編碼了
可能原因是在java類里面調(diào)用了((HttpServletResponse)FacesContext.getCurrentInstance().getExternalContext().getResponse()).getWriter().write("");
然后再轉(zhuǎn)向某個頁面,這樣可能導(dǎo)致編碼格式?jīng)_突,導(dǎo)致亂碼
可以先給resonse設(shè)置下編碼格式,然后在write
HttpServletResponse httpServletResponse = (HttpServletResponse)FacesContext.getCurrentInstance().getExternalContext().getResponse();
httpServletResponse.setContentType("text/html; charset=gb2312");
httpServletResponse.setCharacterEncoding("gb2312");
httpServletResponse.getWriter().write("");
這樣應(yīng)該就可以解決了
C:\Program Files\IBM\WebSphere\AppServer\profiles\AppSrv01\config\cells\app-bi2Node01Cell\applications\appname.ear\deployments\appname\appname.war\WEB-INF\web.xml 該目錄下的web.xml的修改才是有效
應(yīng)用程序發(fā)布的目錄下的那個web.xml添加的servlet配置是無效的
可能原因:
1: form表單中的控件沒有定義name屬性
2: form表單中的控件被設(shè)置成disabled
3: form表單的enctype="multipart/form-data"是一種用于上傳文件的表單
|
解決方法:
對于第三種情況我們直接request.getParameter來取參數(shù)值是取不到的
我們可以借用apache的上傳組件來解決
用到jar包commons-fileupload-1.1.1.jar
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import
org.apache.commons.fileupload.servlet.ServletFileUpload;
/**
*獲取各種類型表單的表單參數(shù)
*@paramrequest HttpServletRequest請求對像
* @paramparamName 參數(shù)名
*@return
*@throwsFileUploadException
*/
publicstatic String
getParameterValue(HttpServletRequest request,String paramName) throws
FileUploadException{
boolean
isMultipart = ServletFileUpload.isMultipartContent(request);
if(isMultipart==true){
FileItemFactory
factory = new DiskFileItemFactory();
ServletFileUpload
upload = new ServletFileUpload(factory);
List
fileItemList = upload.parseRequest(request);
if(fileItemList!=null){
for(Iterator itr=fileItemList.iterator();itr.hasNext();){
FileItem fileItem = (FileItem)itr.next();
if(fileItem.getFieldName().equalsIgnoreCase(paramName)){
return new
String(fileItem.getString().getBytes("ISO8859-1"))//中文轉(zhuǎn)碼
}
}
}
}else{
return new String(request.getParameter(paramName).getBytes("ISO8859-1"))//中文轉(zhuǎn)碼
}
return"";
}
|
1.定義一個標(biāo)簽要用到兩個java類,這個跟jsp的自定義標(biāo)簽有點(diǎn)不一樣
第一個類繼承UIComponentTag, 用于定義標(biāo)簽的屬性和設(shè)置標(biāo)簽的所有屬性值到控件的map屬性attributes或valueBinding中
第二個類繼承UIInput或者UIOutput,用于渲染標(biāo)簽的內(nèi)容,真正打印標(biāo)簽內(nèi)容的地方就在這里
2.這兩個類是怎么聯(lián)系的
我們需要像定義jsf的bean的影射文件一樣,在faces-config.xml或者自己定義的xml文件里面定義第二個類
如:
<faces-config>
<!--分頁標(biāo)簽-->
<component>
<component-type>pageTag</component-type>
<component-class>com.jsf.PageComponent</component-class>
</component>
</faces-config>
然后第一個類要實(shí)現(xiàn)父類的一個方法 public String getComponentType();從這里返回一個字符串pageTag,這樣就跟第二個類聯(lián)系起來了

3.標(biāo)簽屬性的定義
標(biāo)簽屬性的定義一般都是可轉(zhuǎn)化為字符串的類型的,除非你還是用<%=rowList%>這種jsp賦值的方式
別以為你定義的一個List類型的屬性可以用jsf的EL表達(dá)式可以直接賦值進(jìn)來,EL表達(dá)式傳進(jìn)來以后屬性接收的就是這一串EL表達(dá)式
所以就是說你的屬性就是要字符串類型的

4.那么jsf自定義標(biāo)簽是怎么接收EL表達(dá)式綁定的列表的
先通過父類的isValueReference(屬性值),來判斷該屬性的值是否是一個EL的表達(dá)式
如果是則通過獲取綁定值得方式把真正的屬性的值設(shè)置到標(biāo)簽父類的valueBinding對像中
否則直接把屬性的值添加到標(biāo)簽父類的attributes對像中
if (isValueReference(屬性值)) {
javax.faces.el.ValueBinding vb = Util.getValueBinding(value.toString());
component.setValueBinding(name, vb); //component就是標(biāo)簽對像,name就是標(biāo)簽的屬性名稱
} else {
component.getAttributes().put(name, 屬性值);
}
這就是個設(shè)置屬性值的過程,可以在第1點(diǎn)說的第一個類里面的protected void setProperties(UIComponent component)方法
5.現(xiàn)在知道標(biāo)簽屬性值的作用了嗎
是的標(biāo)簽屬性值只不過是起個作用而已,而不是我們真正所要的值
也就是說我們是不能從這些屬性中直接取值的
6.那么我們怎么取屬性的真正的值呢
可以先從第4點(diǎn)說的標(biāo)簽父類的attributes對像中取值
如果取不到值那就到標(biāo)簽父類的valueBinding對像中取值
說白了就是,通過第4步我們屬性的真正的值不是放在attributes就是在valueBinding中
Object obj = component.getAttributes().get(name); //component就是標(biāo)簽對像,name就是標(biāo)簽的屬性名稱
if (obj == null) {
ValueBinding vb = component.getValueBinding(name);
if (vb != null) {
return vb.getValue(context);
} else {
return null;
}
}
這個過程就是取屬性值的過程,在第1點(diǎn)說的第二個類里面進(jìn)行
7.現(xiàn)在屬性值也可以取到了,那么我們要怎么打印標(biāo)簽的內(nèi)容呢
我們可以在第二個類的encodeBegin或者encodeEnd中進(jìn)行
public void encodeBegin(FacesContext context) throws IOException
public void encodeEnd(FacesContext context) throws IOException
取屬性值的過程也可以在這里進(jìn)行,取完值后就是把值組裝到標(biāo)簽內(nèi)容的相應(yīng)位置中就完了
基本上就是這幾點(diǎn)

在本地tomcat5中這樣沒問題
request.getRealPath("/")+"report/config/configFile/"+priv_id+".xml"
但是發(fā)布到websphere6后就出問題了
要改成
request.getRealPath("/")+"/report/config/configFile/"+priv_id+".xml"
就是report前要加個"/" 斜杠,加了后tomcat5下也是正確的
1.jdk環(huán)境問題
jdk環(huán)境要改為ibm 的jdk 5.0, 不然連接不上數(shù)據(jù)庫, 數(shù)據(jù)庫連接池的連接失敗,c3p0連接池的連接失敗,目前還是默認(rèn)的方式采用應(yīng)用服務(wù)器的連接池,像tomcat就采用tomcat配置的連接池
eclipse 的開發(fā)時用的jre如果修改為ibm的以后,有可能會導(dǎo)致編譯不了,這要修改編輯器java類型的編碼為gb2312就可以了,genaral->content type –java file
2. 程序中編寫sql時的用戶模式問題
用戶模式要用公共常量,以便修改
不同用戶模式之間的表的訪問通過授權(quán)來解決
3. db2數(shù)據(jù)庫的函數(shù)問題
程序中的添加和修改時間的地方的日期函數(shù)都要修改成
Date(“2007-01-01”)就是字符串中間有帶中杠的
日期轉(zhuǎn)字符串要把原先的to_char改成char(int(2007-01-01))
Kpi的消息串在配置中在取權(quán)限priv_id的字符串要加上char(int(priv_id)),如果直接char(priv_id)會多出一個點(diǎn)號
4. oracle樹形結(jié)構(gòu)的查詢移植到db2存在問題
菜單查詢中,有存在層次level的沒實(shí)現(xiàn),目前我先通過自己寫的函數(shù)實(shí)現(xiàn),但存在問題跟沒有層次的實(shí)現(xiàn)方式一樣存在問題
因?yàn)橥ㄟ^in的方式,in的存在字段是有限的到時候數(shù)據(jù)量變多了,sql就會執(zhí)行失敗,可以考慮臨時表來解決
5. 序列表seq的長度問題
所有的序列表的序列長度db2是有限制的,好像不能大于8位,這樣序列的字段都要做修改,而且不能重復(fù),要進(jìn)一步確認(rèn)修改
7. 系統(tǒng)權(quán)限移植問題
地區(qū)編碼的字段從數(shù)值型改為字符串類型,很辛苦,建議以后程序的bean的屬性都用字符串來定義,避免程序移植的類型修改的問題
8. erwin數(shù)據(jù)模型問題
數(shù)據(jù)模型中的部分表沒有及時更新,跟開發(fā)時用的表有出入,以后數(shù)據(jù)模型要及時更新
9. 建表的sql語句問題
建表的sql中
number(12) 這樣的都要改成decimal(12,0)
varchar2都要改成varchar
有時候我們在表單提交后卻獲取不到控件的值
可能原因:
1. 控件少了name屬性
2.控件被設(shè)置成disabled
后臺數(shù)據(jù)處理完成的時候設(shè)置一個處理完成的session標(biāo)志
前臺通過發(fā)送ajax請求設(shè)置成功標(biāo)志的session的頁面,如果session的成功標(biāo)志為true則數(shù)據(jù)處理完成,關(guān)閉正在處理的進(jìn)度條圖片,否則繼續(xù)發(fā)送ajax請求,顯示正在處理的進(jìn)度條圖片,當(dāng)然也可以通過后臺返回數(shù)據(jù)處理完成的百分比,來制作精確的進(jìn)度條
當(dāng)我們在做動態(tài)生成checkbox和動態(tài)設(shè)置checkbox的checked屬性的時候要注意
只有checkbox在頁面生成以后設(shè)置checkbox的checked屬性才有效,否則是無效的
也就是說不要在create checkbox后就設(shè)置checked屬性,要等到該checkbox已經(jīng)append到頁面中了在來設(shè)置checked屬性這樣才可以
1) 使用response.sendredirect重定向是沒辦法通過request.setAttribute來傳遞對象到另外一個頁面的
但我們可以通過轉(zhuǎn)發(fā)的方式來實(shí)現(xiàn)request.getRequestDispatcher("test2.jsp").forward(request,response)
這也是struts默認(rèn)的頁面跳轉(zhuǎn)方式,這就是為什么我們可以在action里面request.setAttribute然后在頁面里request.getAttribute
2) 使用response.sendredirect重定向要記得在后面加上return不然后面的語句還是會繼續(xù)往下執(zhí)行的,還有就是response.sendredirect之前最好不要有任何的輸出語句包括html不然可能會重定向失敗
最近我還遇到一個比較奇怪的問題就是response.sendredirect失敗,因?yàn)槲业亩丝谑峭ㄟ^交換機(jī)來轉(zhuǎn)換的所以可能就是在這里重定向不過去了,所以建議以后大家都使用request.getRequestDispatcher("test2.jsp").forward(request,response)這種方式就不會錯了,當(dāng)然也可以用jsp標(biāo)簽的forward
摘要: 1) ICache.java 緩存接口
package com.jgao.cache;/** *//** * 緩存接口 * @author jgao * */public interface ICache {  ...
閱讀全文
??? 基本的思想和步驟都在了,主要就是遞歸
??? /**
???? * 傳入級數(shù)返回存放該級數(shù)下所有組織列表的列表
???? * @param lever int 組織級數(shù)
???? * @return List<List> 存放組織列表
???? */
??? public List<List> getTreeLeverNode(int lever) {
??????? String sqlstr = "select? ID from?table1 where PARENT_ID=0";
??????? Result ret = Dao.executeQuery(sqlstr);
??????? List<List> list = new Vector<List>();
??????? List rslist = new Vector();
??????? List<String> nodeList = new Vector<String>();
??????? for (int i = 0; i < ret.Length(); i++) {
??????????? rslist = getNextNode(Integer.parseInt(ret[i]
??????????????????????? .toString()), lever - 1, nodeList);
??????????????? list.add(rslist);
??????? }
??????? return list;
??? }
??? /**
???? * 返回存放該級數(shù)下所有組織的列表
???? * @param reqParentid 請求傳入的父節(jié)點(diǎn)ID
???? * @param lever 組織級數(shù)
???? * @param list 存放該級數(shù)下所有組織的列表
???? * @return List<String> 存放組織
???? */
??? public List<String> getNextNode(int reqParentid, int lever, List list) {
??????? String sqlstr = "select? ID from?table1 where PARENT_ID="
??????????????? + reqParentid;
??????? DBResult ret = super.executeQuery(sqlstr);
??????? List rslist = new Vector();
??????? lever = lever - 1;
??????? if (lever > 0) {
???????????for (int i = 0; i < ret.Length(); i++) {
?????????????????rslist = getNextNode(Integer.parseInt(ret[i]
??????????????????????? .toString()), lever , nodeList);
??????????????? list.add(rslist);
???????????}
??????? } else {
??????????? for (int i = 0; i < ret.Length(); ; i++) {
????????????????list.add(ret[i].toString());
??????????? }
??????? }
??????? return list;
??? }
剛使用erwin時在連接oracle9i數(shù)據(jù)庫時的那個連接串我一直用jdbc連接oracle的那個格式,所以一直連都連不上
一直出現(xiàn)“內(nèi)部錯誤,hostdef擴(kuò)展名不存在”,很是郁悶,不知大家有沒遇到
后來查了一下,才知道本地的話要進(jìn)行本地的Net服務(wù)名配置
配置工具在開始->oracle->Configuration and Migration Tools->NET CONFIGUATION ASSISTANT
然后選擇本地的Net服務(wù)名配置,在配置到服務(wù)名的時候把你的數(shù)據(jù)庫名稱添進(jìn)去,然后往下到完成就行了
也可以直接編輯tnsnames.ora,如下圖:

接下來在erwin進(jìn)行正向或者反向工程的操作界面,提示連接數(shù)據(jù)庫的那個連接字符串里輸入你的那個服務(wù)名就行了,當(dāng)然用戶名密碼還是要跟之前的一樣,如下圖:

/**
*臨時寫的偽代碼
*/
//獲取第N級的所有節(jié)點(diǎn)
public list getTreeLeverNode(int lever)
??rs0 = select id from menu where parentid is null;? //先從數(shù)據(jù)庫取出第一級的所有節(jié)點(diǎn)
??if(lever<=1)
? return rs0
? //循環(huán)第一級的節(jié)點(diǎn)遞歸取下面的節(jié)點(diǎn)
??for(int i=0; i<rs0.length; i++){
???rslist = getNextNode(rs0[i],lever-1);
???list.add(rslist);
??}
??return rs1;
}
public list getNextNode(int reqParentid,int lever){
??rs2 = select id from menu where parentid = reqParentid;
??lever = lever -1;
??if(lever>0){
???for(int i=0; i<rs2.length; i++){
????rs2 = getNextNode(rs2[i],lever);
????list.add(rs2);
???}
??}
??return rs2;
}
??????1.當(dāng)執(zhí)行一個功能的時候需要執(zhí)行多個更新操作,如:插入多個對象,刪除多個對象等,就可能存在執(zhí)行一個更新操作成功之后下一個更新操作失敗,那么這個功能的執(zhí)行就算是失敗的,可是卻向數(shù)據(jù)庫添加或刪除了不完全的相關(guān)數(shù)據(jù),所以就會出現(xiàn)臟數(shù)據(jù)
??????解決方法:
??????1) 通過事物控制讓多個執(zhí)行語句一起提交commit,commit失敗的話就回滾rollback,做到事物的原子性原則
??????2) 在數(shù)據(jù)庫設(shè)置一個操作成功或失敗的字段(或者本地臨時文件里存放相關(guān)的控制數(shù)據(jù)),通過該字段進(jìn)行控制,在執(zhí)行出錯后刪除所有含有操作失敗字段的數(shù)據(jù)
???????
??????2.數(shù)據(jù)庫同步訪問控制:比如說一條記錄有兩個以上的用戶同時訪問,他們讀取出來的是相同的數(shù)據(jù),但寫入時有先后,如果不做控制就會出現(xiàn)后來寫入的數(shù)據(jù)把原來做了更新的數(shù)據(jù)覆蓋,使原來做的更新操作丟失就是無效,因?yàn)樗麄兌际窃谧钤甲x取出來的數(shù)據(jù)上做的修改,而不是在別人做了修改后的數(shù)據(jù)上做修改
??????解決方法:
??????1) 可以在數(shù)據(jù)庫多設(shè)置一個版本字段來控制該數(shù)據(jù)的歷史版本號(或者本地臨時文件里存放相關(guān)的控制數(shù)據(jù)),就是沒個人做了修改以后都要更新一下這個版本字段,同時更新之前也要做一下版本的比較,如果現(xiàn)在的版本和之前取出來的數(shù)據(jù)的版本不一樣,那么就要從新讀取數(shù)據(jù)再寫入,這樣就可以保證不會丟失修改
?????
錯誤如下:
Servlet: "Faces" failed to preload on startup in Web application
我的方法是修改web.xml如下:
<?xml version="1.0" encoding="gb2312"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee?? http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
?<context-param>
??<param-name>javax.faces.CONFIG_FILES</param-name>
??<param-value>/WEB-INF/faces-config.xml</param-value>
?</context-param>
?
? //listener節(jié)點(diǎn)是新加的
?<listener>
??<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
?</listener>
?
?<servlet>
??<servlet-name>Faces Servlet</servlet-name>
??<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
??<load-on-startup>-1</load-on-startup>//本來是0先在改為-1
?</servlet>
?
?<servlet-mapping>
??<servlet-name>Faces Servlet</servlet-name>
??<url-pattern>*.faces</url-pattern>
?</servlet-mapping>
</web-app>
tomcat要同時開多個端口只要配置conf文件夾下面的server.xml增加Service節(jié)點(diǎn)就可以了,如下我多開了個8083端口,同時我把Catalina文件夾多拷貝了一份另存為Catalina2
<Server port="8005" shutdown="SHUTDOWN" debug="0">
? <!-- Comment out these entries to disable JMX MBeans support -->
? <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"
??????????? debug="0"/>
? <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"
??????????? debug="0"/>
? <!-- Global JNDI resources -->
? <GlobalNamingResources>
??? <!-- Test entry for demonstration purposes -->
??? <Environment name="simpleValue" type="java.lang.Integer" value="30"/>
??? <!-- Editable user database that can also be used by
???????? UserDatabaseRealm to authenticate users -->
??? <Resource name="UserDatabase" auth="Container"
????????????? type="org.apache.catalina.UserDatabase"
?????? description="User database that can be updated and saved">
??? </Resource>
??? <ResourceParams name="UserDatabase">
????? <parameter>
??????? <name>factory</name>
??????? <value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
????? </parameter>
????? <parameter>
??????? <name>pathname</name>
??????? <value>conf/tomcat-users.xml</value>
????? </parameter>
??? </ResourceParams>
? </GlobalNamingResources>
? <!-- Define the Tomcat Stand-Alone Service -->
? <Service name="Catalina">
??? <!-- Define a non-SSL Coyote HTTP/1.1 Connector on the port specified
???????? during installation -->
??? <Connector
port="8081"?????????????? maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
?????????????? enableLookups="false" redirectPort="8443" acceptCount="100"
?????????????? debug="0" connectionTimeout="20000"
?????????????? disableUploadTimeout="true" />
??? <!-- Define a Coyote/JK2 AJP 1.3 Connector on port 8009 -->
??? <Connector port="8009"
?????????????? enableLookups="false" redirectPort="8443" debug="0"
?????????????? protocol="AJP/1.3" />
????????
??? <!-- Define the top level container in our container hierarchy -->
??? <Engine name="Catalina" defaultHost="localhost" debug="0">
????? <!--
????? <Valve className="org.apache.catalina.valves.RequestDumperValve"/>
????? -->
????? <!-- Global logger unless overridden at lower levels -->
????? <Logger className="org.apache.catalina.logger.FileLogger"
????????????? prefix="catalina_log." suffix=".txt"
????????????? timestamp="true"/>
????? <!-- This Realm uses the UserDatabase configured in the global JNDI
?????????? resources under the key "UserDatabase".? Any edits
?????????? that are performed against this UserDatabase are immediately
?????????? available for use by the Realm.? -->
????? <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
???????????????? debug="0" resourceName="UserDatabase"/>
????? <!-- Define the default virtual host -->
????? <Host name="localhost" debug="0" appBase="webapps"
?????? unpackWARs="true" autoDeploy="true">
??????? <Logger className="org.apache.catalina.logger.FileLogger"
???????????????? directory="logs"? prefix="localhost_log." suffix=".txt"
??????????? timestamp="true"/>
??????? <!--
????????? <Context path="" docBase="ROOT" debug="0">
??????? -->
????? </Host>
??? </Engine>
? </Service>
?
??? <Service name="Catalina2">
??? <Connector
port="8083"?????????????? maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
?????????????? enableLookups="false" redirectPort="8443" acceptCount="100"
?????????????? debug="0" connectionTimeout="20000"
?????????????? disableUploadTimeout="true" />
??? <!-- Define a Coyote/JK2 AJP 1.3 Connector on port 8009 -->
??? <Connector port="8010"
?????????????? enableLookups="false" redirectPort="8443" debug="0"
?????????????? protocol="AJP/1.3" />
????????
??? <!-- Define the top level container in our container hierarchy -->
??? <Engine name="Catalina2" defaultHost="localhost" debug="0">
????? <!-- Global logger unless overridden at lower levels -->
????? <Logger className="org.apache.catalina.logger.FileLogger"
????????????? prefix="catalina_log." suffix=".txt"
????????????? timestamp="true"/>
????? <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
???????????????? debug="0" resourceName="UserDatabase"/>
????? <Host name="localhost" debug="0" appBase="webapps"
?????? unpackWARs="true" autoDeploy="true">
??????? <Logger className="org.apache.catalina.logger.FileLogger"
???????????????? directory="logs"? prefix="localhost_log." suffix=".txt"
??????????? timestamp="true"/>
????? </Host>
??? </Engine>
? </Service>
</Server>
我剛配置時出現(xiàn)的錯誤及解決方法:
1.啟動時出現(xiàn)如下錯誤
The WebLogic Server did not start up properly.
java.io.InvalidClassException: javax.management.MBeanAttributeInfo; local class incompatible: stream classdesc serialVersionUID = 7043855487133450673, local class serialVersionUID = 8644704819898565848
?at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:519)
?at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1546)
?at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1460)
?at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1546)
?at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1460)
?at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1693)
?at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
?at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1628)
?at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1293)
?at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1912)
?at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1836)<2006-12-6 下午05時39分36秒 CST> <Info> <Configuration Management> <BEA-150016> <This server is being started as the administration server.>
<2006-12-6 下午05時39分36秒 CST> <Info> <Management> <BEA-141107> <Version: WebLogic Server 8.1 SP2? Fri Dec 5 15:01:51 PST 2003 316284
WebLogic XMLX Module 8.1 SP2? Fri Dec 5 15:01:51 PST 2003 316284 >
原因是配置weblogic時用了jdk1.5改成weblogic自帶的jdk1.4就可以解決了
2.啟動時出現(xiàn)如下錯誤
***************************************************************************
The WebLogic Server did not start up properly.
Exception raised: 'weblogic.management.configuration.ConfigurationException: Unable to locate server named myServer in the configuration file config.xml. Please ensure the argument -Dweblogic.Name=<serverName> matches a server name in that file, for example: <Server ... Name="someName"/>.A single server was found namedmyserver'
Reason: weblogic.management.configuration.ConfigurationException: Unable to locate server named myServer in the configuration file config.xml. Please ensure the argument -Dweblogic.Name=<serverName> matches a server name in that file, for example: <Server ... Name="someName"/>.A single server was found namedmyserver
***************************************************************************
原因是配置weblogic信息時的內(nèi)容跟你的F:\bea\user_projects\domains\mydomain\config.xml文件里的內(nèi)容不一致包括大小寫,改過來就行了
主要是domain name和server name 如下是mydomain和myserver
<Domain ConfigurationVersion="8.1.2.0" Name="mydomain">
??? <Server ListenAddress="localhost" ListenPort="7001" Name="myserver"
很多人剛開始在用jdbc連接sqlserver時都出現(xiàn)問題,也就是連接不上
大部分的什么配置工作啊,驅(qū)動程序啊,程序的連接語句啊這些相信都沒錯,因?yàn)榫W(wǎng)上隨便都能找到,而且說得也很清楚了
最主要的一個原因可能就是sp3補(bǔ)丁沒打,打完后或許就能連接上了
?var row=document.createElement('tr');
?row.setAttribute('bgcolor','#00CCFF');
這樣設(shè)置了半天就是沒效果,找了半天就是找不出原因
后來我直接在頁面上寫
<tr bgcolor="#00CCFF"></tr>然后在程序里innerHTML
發(fā)現(xiàn)兩個bgcolor打印出來是不一樣的
我程序里的是原樣的bgcolor而靜態(tài)寫好的bgcolor卻變成bgColor看到?jīng)]c變成了大寫了,然后我也跟著改成?
row.setAttribute('bgColor','#00CCFF');神了真的就可以了,哎無語啊!
本程序?qū)jax的一些基礎(chǔ)調(diào)用進(jìn)行了封裝,使用者只要實(shí)現(xiàn)具體的事件驅(qū)動程序就可以
了,如本例子的doTest.js, 然后把該文件引進(jìn)相對應(yīng)的jsp文件里面,如test.jsp
test.jsp
<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>
<script src="ajaxjs/ajaxInit.js" type="text/javascript"></script>
<script src="ajaxjs/doTest.js" type="text/javascript"></script>
<html>
? <body>
? <input name="testText" type="text" value="">
? <input type="button" value="test" onclick="doTestRequest(document.getElementById('testText').value,'jgaopass','doTestAfterRequest','responseText');">
? </body>
</html>
doTest.js
//測試函數(shù)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* 請求
* doAfterRequestMethodName 請求成功后的要執(zhí)行的函數(shù)名稱
* responseTypeName ajax異步調(diào)用后返回的內(nèi)容的類型,可以使responseText或者responseXml
*/
function doTestRequest(userName, userPwd, doAfterRequestMethodName, responseTypeName){?
?var param = setQueryString('userName',userName,'userPwd',userPwd);
?sendRequest('toStrutsAjaxTest.do',param,doAfterRequestMethodName,responseTypeName);
}
//請求成功后的執(zhí)行內(nèi)容
function doTestAfterRequest(responseString){
?var teststring = document.getElementById("testText");
?teststring.value = responseString;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ajaxInit.js
//全局變量
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var xmlHttp = false;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////??
//公共函數(shù)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//創(chuàng)建XMLHttpRequest對象
function createXMLHttpRequest() {???
?if (window.XMLHttpRequest) {//Mozilla 等瀏覽器??? ?
??xmlHttp = new XMLHttpRequest();
??? ?} else {?? ??
??? ??if (window.ActiveXObject) {// IE瀏覽器
??? ???try {
??? ????xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
??? ???}
??? ???catch (e) {
??? ????try {
??? ???? ?xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
??? ????}
??????????????? ??catch (e) {
??????????????? ??}
????????? ??}
????? ??}
?}
? ?if (xmlHttp.overrideMimeType) {//修改MiME類型
? ??xmlHttp.overrideMimeType("text/xml");
? ?}??
? ?if (!xmlHttp) {//創(chuàng)建XMLHttpRequest失敗
? ??window.alert("創(chuàng)建XMLHttpRequest失敗");
?? ??return false;
? ?}
}
//向后臺發(fā)送請求的參數(shù)設(shè)置
function setQueryString(){
?var param="";
??for(var i=0;i<arguments.length;i++){
??param+=arguments[i]+'='+encodeURI(arguments[i+1]);
??if(i!=arguments.length-2){
???param+="&";
???i++;
??}else{
???break;
??}?
?}
?return param;
}
/**
* 發(fā)送請求
* doAfterRequestMethodName 請求成功后的要執(zhí)行的函數(shù)名稱
* responseTypeName ajax異步調(diào)用后返回的內(nèi)容的類型,可以使responseText或者responseXml
*/
function sendRequest(requestUrl,param,doAfterRequestMethodName,responseTypeName){
?createXMLHttpRequest();?
?xmlHttp.open('POST',requestUrl,true);
?xmlHttp.setrequestheader("content-type","application/x-www-form-urlencoded");
?xmlHttp.onreadystatechange= function(){regCallBack(doAfterRequestMethodName,responseTypeName);};
?xmlHttp.send(param);
}
//回調(diào)函數(shù)
function regCallBack(doAfterRequestMethodName,responseTypeName){?
?if(xmlHttp.readyState == 4){
??if(xmlHttp.status == 200){
????? ???doAfterRequest(doAfterRequestMethodName,responseTypeName);
??}
?}
}
//請求成功后的執(zhí)行函數(shù)
function doAfterRequest(doAfterRequestMethodName,responseTypeName){
?var responseString = "";
?if (responseTypeName!=null){
??if (responseTypeName == "responseText"){
???responseString = xmlHttp.responseText;
??}
??if (responseTypeName == "responseXml"){
???responseString = xmlHttp.responseXml;
??}
?}?
?if(doAfterRequestMethodName!=null){
??eval(doAfterRequestMethodName+"('"+responseString+"')");
?}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
struts-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "
http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd
">
<struts-config>
? <data-sources />
? <form-beans />
? <global-exceptions />
? <global-forwards />
? <action-mappings >
??? <action path="/toStrutsAjaxTest" type="com.jgao.ajax.test.struts.action.ToStrutsAjaxTestAction">
?</action>
? </action-mappings>
? <message-resources parameter="com.yourcompany.struts.ApplicationResources" />
</struts-config>
ToStrutsAjaxTestAction.java
//Created by MyEclipse Struts
// XSL source (default): platform:/plugin/com.genuitec.eclipse.cross.easystruts.eclipse_4.1.0/xslt/JavaClass.xsl
package com.jgao.ajax.test.struts.action;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
/**
?* MyEclipse Struts
?* Creation date: 09-18-2006
?*
?* XDoclet definition:
?* @struts.action validate="true"
?*/
public class ToStrutsAjaxTestAction extends Action {
?// --------------------------------------------------------- Instance Variables
?// --------------------------------------------------------- Methods
?/**
? * Method execute
? * @param mapping
? * @param form
? * @param request
? * @param response
? * @return ActionForward
? * @throws IOException
? */
?public ActionForward execute(
??ActionMapping mapping,
??ActionForm form,
??HttpServletRequest request,
??HttpServletResponse response) throws IOException {
??String teststring = request.getParameter("userName");
??teststring = teststring + "ok";
?? response.getWriter().write(teststring);
??return null;
?}
}
摘要: java
開發(fā)出錯筆記
---powered by jgao
1.
...
閱讀全文
1.java 2D主要繪圖類描述(jdk1.5)
?Graphics2D //主要繪圖對象,每種圖形都要通過該對象來繪制
?Rectangle2D //長方形對象
?Point2D //點(diǎn)對象
?Line2D //線對象
?Arc2D.Double //弧形對象
?Ellipse2D //橢圓對象
?Polygon //多邊形對象
?Paint //油漆桶對象,用來定義顏色
?Stroke //畫筆對象,主要用于描繪輪廓,定義線條樣式
?Area //幾何建模對象(含幾何并交差運(yùn)算等方法)
?GeneralPath //路徑對象
?
?1.1 sample demo eg:
??/**
?? * 利用路徑對象繪制平面圖
?? */
??// GeneralPath bar3dRight = new GeneralPath();
??// bar3dRight.moveTo((float) 100.0, (float) 100.0);
??// bar3dRight.lineTo((float) 200.0, (float) 200.0);
??// bar3dRight.lineTo((float) 300.0, (float) 100.0);
??// bar3dRight.lineTo((float) 100.0, (float) 100.0);
??// bar3dRight.closePath();
??// 填充四邊形的顏色
??// if (itemPaint instanceof Color) {
??// g2.setPaint(((Color) itemPaint).darker());
??// }
??
??/**
?? * 長方形對象加路徑對象繪制3D柱狀圖
?? */
??//正視圖
??Rectangle2D r2d = new Rectangle2D.Double(
????100.0, //x
????100.0, //y
????30.0, //width
????200.0 //hight
????);
??//右視圖
??GeneralPath bar3dRight = new GeneralPath();
??bar3dRight.moveTo((float) 130.0, (float) 100.0);
??bar3dRight.lineTo((float) 150.0, (float) 90.0);
??bar3dRight.lineTo((float) 150.0, (float) 290.0);
??bar3dRight.lineTo((float) 130.0, (float) 300.0);
??bar3dRight.closePath();
??//俯視圖
??GeneralPath bar3dTop = new GeneralPath();
??bar3dTop.moveTo((float) 100.0, (float) 100.0);
??bar3dTop.lineTo((float) 130.0, (float) 100.0);
??bar3dTop.lineTo((float) 150.0, (float) 90.0);
??bar3dTop.lineTo((float) 120.0, (float) 90.0);
??bar3dTop.closePath();
??Paint barpaint = Color.PINK; // 實(shí)體顏色
??Paint outlinepaint = Color.DARK_GRAY; // 輪廓線顏色
??float dash1[] = { 10.0f };
??// 虛線條描邊
??// Stroke stroke = new BasicStroke(1.0f,
??// BasicStroke.CAP_BUTT,
??// BasicStroke.JOIN_MITER,
??// 10.0f, dash1, 0.0f);
??
??// 實(shí)線條描邊,寬度1.0f
??Stroke stroke = new BasicStroke(1.0f);
??// g2.setColor(Color.PINK);
??// 先設(shè)置實(shí)體顏色
??g2.setPaint(barpaint);
??g2.setStroke(stroke);
??g2.fill(r2d);
??g2.fill(bar3dRight);
??g2.fill(bar3dTop);
??// 實(shí)體填充進(jìn)繪圖對象以后,在設(shè)置輪廓線顏色(其實(shí)是上面三個實(shí)體以外的所有圖形的顏色)
??g2.setPaint(outlinepaint);
??g2.draw(r2d);
??g2.draw(bar3dRight);
??g2.draw(bar3dTop);
??/**
?? * 利用橢圓對象繪制橢圓
?? */
??Ellipse2D ellipse2D = new Ellipse2D.Double(200.0, // x
????100.0, // y
????200.0, // width
????200.0 // hight
??);
??Paint ellipsepaint = Color.blue;
??g2.setPaint(ellipsepaint);
??g2.fill(ellipse2D);
??g2.draw(ellipse2D);
??/**
?? * 利用弧形對象繪制弧形
?? */
??Arc2D.Double arc = new Arc2D.Double(350.0, // x
????100.0, // y
????200.0, // width
????200.0, // hight
????0.0, // start angle
????90.0, // arc angle
????Arc2D.PIE // pie:3.1415926
??);
??Arc2D.Double arc2 = new Arc2D.Double(350.0, // x
????100.0, // y
????200.0, // width
????200.0, // hight
????-60.0, // start angle
????90.0, // arc angle
????Arc2D.PIE // pie:3.1415926
??);
??Paint arcpaint1 = Color.GREEN;
??Paint arcpaint2 = Color.RED;
??// 設(shè)置透明度
??g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
????0.3f));
??g2.setPaint(arcpaint1);
??g2.fill(arc);
??g2.draw(arc);
??g2.setPaint(arcpaint2);
??g2.fill(arc2);
??g2.draw(arc2);
??/**
?? * 圖形的幾何運(yùn)算
?? */
??// Area a = new Area(arc);
??// Area b = new Area(arc2);
??// ab交差運(yùn)算,去掉兩個圖形相交的部分得到的圖形
??// a.exclusiveOr(b);
??// a交b運(yùn)算
??// a.intersect(b);
??// a減去b運(yùn)算,即差運(yùn)算
??// a.subtract(b);
??// a并b運(yùn)算
??// a.add(b);
??// g2.setPaint(arcpaint2);
??// g2.fill(a);
??// g2.draw(a);
??
??/**
?? * 利用jfreechart的TextBox對象繪制文本框
?? */
??// 設(shè)置透明度為1,也就是不透明了
??g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
????1.0f));
??TextBox textBox = new TextBox("java" // 想要顯示的字符串
??);
??textBox.draw(g2, // 繪圖對象
????(float) 550.0, // x坐標(biāo)
????(float) 100.0, // y坐標(biāo)
????RectangleAnchor.CENTER // 對齊方式
????);
??Line2D.Double line = new Line2D.Double(522.0, // 線的第一個點(diǎn)的x坐標(biāo)
????100.0, // 線的第一個點(diǎn)的y坐標(biāo)
????500.0, // 線的第二個點(diǎn)的x坐標(biāo)
????120.0 // 線的第二個點(diǎn)的y坐標(biāo)
??);
??g2.draw(line);
??/**
?? * 寫字
?? */
??// 字體設(shè)置
??Font font = new Font(null, // 字體
????Font.ITALIC + Font.BOLD, // 樣式(這里設(shè)置了兩種樣式,黑體+斜體)
????10); // 大小
??g2.setFont(font);
??Paint arcpaint3 = Color.BLACK;
??g2.setPaint(arcpaint3);
??g2.drawString("delphi", // 要寫的字符串
????550, // x坐標(biāo)
????150 // y坐標(biāo)
????);
????
?? /**
?? * 利用多邊形對象繪制多邊形
?? */
??int []xs = new int[] { 600, 620,
????640, 620 };
??int []ys = new int[] { 100,
????100, 150,
????150};???
??Polygon polygon = new Polygon(
????xs, //多邊形x坐標(biāo)點(diǎn)的數(shù)組
????ys, //多邊形y坐標(biāo)點(diǎn)的數(shù)組
????4 //數(shù)組大小
????);
??g2.setPaint(java.awt.Color.lightGray);
??g2.fill(polygon);
??g2.draw(polygon);
??
??/**
?? * 畫網(wǎng)格線
?? */?
??for(double i=0.0; i<450.0; i+=30.0){
???// 網(wǎng)格線樣式
????? Stroke DEFAULT_GRIDLINE_STROKE = new BasicStroke(0.5f,
????????????? BasicStroke.CAP_BUTT,
????????????? BasicStroke.JOIN_BEVEL,
????????????? 0.0f,
????????????? new float[] {2.0f, 2.0f},
????????????? 0.0f);
????? Line2D.Double gridline = new Line2D.Double(0.0,i+30.0,700.0,i+30.0);
????? g2.setPaint(Color.GRAY);
????? g2.setStroke(DEFAULT_GRIDLINE_STROKE);
????? g2.draw(gridline);
??}
2.柱狀圖2D和3D是通過CategoryPlot的renderer屬性來區(qū)別的
?BarRenderer //2DBarRenderer
?BarRenderer3D //3DBarRenderer
?CategoryPlot plot = new CategoryPlot(
??????????? dataset, categoryAxis, valueAxis, renderer
??????? );
3.3D餅圖的繪制函數(shù)(現(xiàn)在的注釋還不夠全面,也可能存在錯誤)
?/**
? * Draws the plot on a Java 2D graphics device (such as the screen or a
? * printer). This method is called by the {@link org.jfree.chart.JFreeChart}
? * class, you don't normally need to call it yourself.
? *
? * @param g2
? *??????????? the graphics device.
? * @param plotArea
? *??????????? the area within which the plot should be drawn.
? * @param anchor
? *??????????? the anchor point.
? * @param parentState
? *??????????? the state from the parent plot, if there is one.
? * @param info
? *??????????? collects info about the drawing (<code>null</code>
? *??????????? permitted).
? */
?public void draw(Graphics2D g2, Rectangle2D plotArea, Point2D anchor,
???PlotState parentState, PlotRenderingInfo info) {
??// adjust for insets...
??RectangleInsets insets = getInsets();
??insets.trim(plotArea);
??Rectangle2D originalPlotArea = (Rectangle2D) plotArea.clone();
??if (info != null) {
???info.setPlotArea(plotArea);
???info.setDataArea(plotArea);
??}
??Shape savedClip = g2.getClip();
??g2.clip(plotArea);
??// adjust the plot area by the interior spacing value
??double gapPercent = getInteriorGap();
??double labelPercent = 0.0;
??if (getLabelGenerator() != null) {
???labelPercent = getLabelGap() + getMaximumLabelWidth()
?????+ getLabelLinkMargin();
??}
??// 水平方向的間隙
??double gapHorizontal = plotArea.getWidth()
????* (gapPercent + labelPercent);
??// 垂直方向的間隙
??double gapVertical = plotArea.getHeight() * gapPercent;
??// x坐標(biāo)大小
??double linkX = plotArea.getX() + gapHorizontal / 2;
??// y坐標(biāo)大小
??double linkY = plotArea.getY() + gapVertical / 2;
??// 圖形寬度
??double linkW = plotArea.getWidth() - gapHorizontal;
??// 圖形高度
??double linkH = plotArea.getHeight() - gapVertical;
??// make the link area a square if the pie chart is to be circular...
??if (isCircular()) { // is circular?
???double min = Math.min(linkW, linkH) / 2;
???linkX = (linkX + linkX + linkW) / 2 - min;
???linkY = (linkY + linkY + linkH) / 2 - min;
???linkW = 2 * min;
???linkH = 2 * min;
??}
??PiePlotState state = initialise(g2, plotArea, this, null, info);
??// the explode area defines the max circle/ellipse for the exploded pie
??// sections.
??// it is defined by shrinking the linkArea by the linkMargin factor.
??double hh = linkW * getLabelLinkMargin();
??double vv = linkH * getLabelLinkMargin();
??Rectangle2D explodeArea = new Rectangle2D.Double(linkX + hh / 2.0,
????linkY + vv / 2.0, linkW - hh, linkH - vv);
??state.setExplodedPieArea(explodeArea);
??// the pie area defines the circle/ellipse for regular pie sections.
??// it is defined by shrinking the explodeArea by the explodeMargin
??// factor.
??double maximumExplodePercent = getMaximumExplodePercent();
??double percent = maximumExplodePercent / (1.0 + maximumExplodePercent);
??double h1 = explodeArea.getWidth() * percent;
??double v1 = explodeArea.getHeight() * percent;
??Rectangle2D pieArea = new Rectangle2D.Double(explodeArea.getX() + h1
????/ 2.0, explodeArea.getY() + v1 / 2.0, explodeArea.getWidth()
????- h1, explodeArea.getHeight() - v1);
??// 定義3D橢圓的高度
??int depth = (int) (pieArea.getHeight() * this.depthFactor);
??// the link area defines the dog-leg point for the linking lines to
??// the labels
??Rectangle2D linkArea = new Rectangle2D.Double(linkX, linkY, linkW,
????linkH - depth);
??state.setLinkArea(linkArea);
??state.setPieArea(pieArea);
??// 定義橢圓中心點(diǎn)
??state.setPieCenterX(pieArea.getCenterX());
??state.setPieCenterY(pieArea.getCenterY() - depth / 2.0);
??// 定義橢圓寬的半徑
??state.setPieWRadius(pieArea.getWidth() / 2.0);
??// 定義橢圓高的半徑
??state.setPieHRadius((pieArea.getHeight() - depth) / 2.0);
??// 畫背景長方形(500*300)區(qū)域
??drawBackground(g2, plotArea);
??// 獲取外面?zhèn)鬟M(jìn)來3D餅圖的數(shù)據(jù)源
??PieDataset dataset = getDataset();??
??// 如果數(shù)據(jù)源為空則直接返回,整個圖表就一個背景長方形沒有數(shù)據(jù)圖形
??if (DatasetUtilities.isEmptyOrNull(getDataset())) {
???drawNoDataMessage(g2, plotArea);
???g2.setClip(savedClip);
???drawOutline(g2, plotArea);
???return;
??}
??/**
?? * 如果數(shù)據(jù)源的主鍵的個數(shù)大于圖形區(qū)域的寬度,則在圖形上顯示"Too many elements" 數(shù)據(jù)源示例如下: final
?? * DefaultPieDataset result = new DefaultPieDataset();
?? * result.setValue("Java", new Double(43.2));
?? * result.setValue("VisualBasic", new Double(10.0));
?? * result.setValue("C/C++", new Double(17.5));
?? * result.setValue("PHP", new Double(32.5));
?? * result.setValue("Perl", new Double(1.0));
?? * return result;
?? * 這個數(shù)據(jù)源的主鍵的個數(shù)為5
?? */
??if (dataset.getKeys().size() > plotArea.getWidth()) {
???String text = "Too many elements";
???Font sfont = new Font("dialog", Font.BOLD, 10);
???g2.setFont(sfont);
???FontMetrics fm = g2.getFontMetrics(sfont);
???int stringWidth = fm.stringWidth(text);
???g2
?????.drawString(text, (int) (plotArea.getX() + (plotArea
???????.getWidth() - stringWidth) / 2), (int) (plotArea
???????.getY() + (plotArea.getHeight() / 2)));
???return;
??}
??
??// if we are drawing a perfect circle, we need to readjust the top left
??// coordinates of the drawing area for the arcs to arrive at this
??// effect.
??// 如果我們畫的是一個圓形那只要知道圖形的左邊距,上邊距,和直徑
??if (isCircular()) {
???// 圓形半徑(取寬高中的小的那個數(shù)的一半)
???double min = Math.min(plotArea.getWidth(), plotArea.getHeight()) / 2;
???plotArea = new Rectangle2D.Double(
?????plotArea.getCenterX() - min, //左邊距(新的圖形的中心點(diǎn)x坐標(biāo))
?????plotArea.getCenterY() - min, //上邊距(新的圖形的中心點(diǎn)y坐標(biāo))
?????2 * min, //直徑(圖形的寬度)
?????2 * min //直徑(圖形的高度)
?????);
??}
??
??// 獲取數(shù)據(jù)源主鍵列表
??List sectionKeys = dataset.getKeys();
??// 如果數(shù)據(jù)源主鍵列表為空,退出
??if (sectionKeys.size() == 0) {
???return;
??}
??// establish the coordinates of the top left corner of the drawing area
??//確定pieArea區(qū)域的中心點(diǎn)
??double arcX = pieArea.getX();
??double arcY = pieArea.getY();
??// g2.clip(clipArea);
??Composite originalComposite = g2.getComposite();
??g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
????getForegroundAlpha()));
??
??//把數(shù)據(jù)源每個主鍵對應(yīng)的值加起來
??double totalValue = DatasetUtilities.calculatePieDatasetTotal(dataset);
??
??//遍歷列表的時候用到
??double runningTotal = 0;
??
??//如果高度<0退出
??if (depth < 0) {
???return; // if depth is negative don't draw anything
??}
??//弧形的列表(用于添加主鍵的值對應(yīng)的弧形)
??ArrayList arcList = new ArrayList();
??//定義一個弧行
??Arc2D.Double arc;
??//定義油漆桶,用來填充顏色
??Paint paint;
??Paint outlinePaint;
??//用于描繪輪廓的樣式
??Stroke outlineStroke;
??
??//遍歷取出主鍵的值對應(yīng)的弧形放到弧形列表
??Iterator iterator = sectionKeys.iterator();
??while (iterator.hasNext()) {
???// 取出主鍵的值
???Comparable currentKey = (Comparable) iterator.next();???
???Number dataValue = dataset.getValue(currentKey);
???
???// 如果主鍵的值為空,則弧形為空
???if (dataValue == null) {
????arcList.add(null);
????continue;
???}
???
???// 如果主鍵的值<=0,則弧形為空
???double value = dataValue.doubleValue();
???if (value <= 0) {
????arcList.add(null);
????continue;
???}
???
???//弧形的開始角度(從該角度算起,相當(dāng)于360度的0度)
???double startAngle = getStartAngle();
???//方向
???double direction = getDirection().getFactor();
???//角度大小1(該主鍵對應(yīng)的弧形的開始角度)
???double angle1 = startAngle + (direction * (runningTotal * 360))
?????/ totalValue;
???//角度大小2(該主鍵對應(yīng)的弧形的結(jié)束角度)
???double angle2 = startAngle
?????+ (direction * (runningTotal + value) * 360) / totalValue;
???
???//如果弧形的角度大小<0.00001則該弧形為空
???if (Math.abs(angle2 - angle1) > getMinimumArcAngleToDraw()) {
????arcList.add(new Arc2D.Double(arcX, arcY + depth, pieArea
??????.getWidth(), pieArea.getHeight() - depth, angle1,
??????angle2 - angle1, Arc2D.PIE));
???} else {
????arcList.add(null);
???}
???
???//轉(zhuǎn)入下個弧形(主鍵對應(yīng)的圖形)
???runningTotal += value;
??}
??
??//取出剪裁的圖形(500*300)
??Shape oldClip = g2.getClip();
??//3D餅圖中上面的橢圓
??Ellipse2D top = new Ellipse2D.Double(pieArea.getX(), pieArea.getY(),
????pieArea.getWidth(), pieArea.getHeight() - depth);
??// 3D餅圖中底部的橢圓
??Ellipse2D bottom = new Ellipse2D.Double(pieArea.getX(), pieArea.getY()
????+ depth, pieArea.getWidth(), pieArea.getHeight() - depth);??
??//底部的長方形
??Rectangle2D lower = new Rectangle2D.Double(top.getX(),
????top.getCenterY(), pieArea.getWidth(), bottom.getMaxY()
??????- top.getCenterY());
??//上部的長方形
??Rectangle2D upper = new Rectangle2D.Double(pieArea.getX(), top.getY(),
????pieArea.getWidth(), bottom.getCenterY() - top.getY());
??
??// Area幾何建模對象
??Area a = new Area(top);
??a.add(new Area(lower));
??Area b = new Area(bottom);
??b.add(new Area(upper));
??Area pie = new Area(a);
??// 通過幾何建模對象對上面的圖形進(jìn)行交叉運(yùn)算
??pie.intersect(b);
??Area front = new Area(pie);
??// 相減運(yùn)算
??front.subtract(new Area(top));
??Area back = new Area(pie);
??// 相減運(yùn)算
??back.subtract(new Area(bottom));
??// draw the bottom circle
??int[] xs;
??int[] ys;
??outlinePaint = getSectionOutlinePaint(0);
??arc = new Arc2D.Double(arcX, arcY + depth, pieArea.getWidth(), pieArea
????.getHeight()
????- depth, 0, 360, Arc2D.PIE);
??// 畫出3D餅圖下部的橢圓的弧形和有該圖形的高度組成的多邊形
??int categoryCount = arcList.size();
??for (int categoryIndex = 0; categoryIndex < categoryCount; categoryIndex++) {
???//取出弧形
???arc = (Arc2D.Double) arcList.get(categoryIndex);
???if (arc == null) {
????continue;
???}
???paint = getSectionPaint(categoryIndex);
???outlinePaint = getSectionOutlinePaint(categoryIndex);
???outlineStroke = getSectionOutlineStroke(categoryIndex);
???g2.setPaint(paint);
???//填充弧形
???g2.fill(arc);
???g2.setPaint(outlinePaint);
???g2.setStroke(outlineStroke);
???//繪制弧形
???g2.draw(arc);
???g2.setPaint(paint);
???
???//取得弧形的開始點(diǎn)
???Point2D p1 = arc.getStartPoint();
???// 定義多邊形(弧形的高度組成的圖形)
???xs = new int[] { (int) arc.getCenterX(), (int) arc.getCenterX(),
?????(int) p1.getX(), (int) p1.getX() };
???ys = new int[] { (int) arc.getCenterY(),
?????(int) arc.getCenterY() - depth, (int) p1.getY() - depth,
?????(int) p1.getY() };???
???Polygon polygon = new Polygon(
?????xs, //多邊形x坐標(biāo)點(diǎn)的數(shù)組
?????ys, //多邊形y坐標(biāo)點(diǎn)的數(shù)組
?????4 //數(shù)組大小
?????);
???g2.setPaint(java.awt.Color.lightGray);
???g2.fill(polygon);
???g2.setPaint(outlinePaint);
???g2.setStroke(outlineStroke);
???//繪制該多邊形
???g2.draw(polygon);
???g2.setPaint(paint);
??}
??g2.setPaint(Color.gray);
??g2.fill(back);
??g2.fill(front);
??// cycle through once drawing only the sides at the back...
??// 描出背部的邊
??int cat = 0;
??iterator = arcList.iterator();
??while (iterator.hasNext()) {
???Arc2D segment = (Arc2D) iterator.next();
???if (segment != null) {
????paint = getSectionPaint(cat);
????outlinePaint = getSectionOutlinePaint(cat);
????outlineStroke = getSectionOutlineStroke(cat);
????drawSide(g2, pieArea, segment, front, back, paint,
??????outlinePaint, outlineStroke, false, true);
???}
???cat++;
??}
??// cycle through again drawing only the sides at the front...
??// 描出前面的邊
??cat = 0;
??iterator = arcList.iterator();
??while (iterator.hasNext()) {
???Arc2D segment = (Arc2D) iterator.next();
???if (segment != null) {
????paint = getSectionPaint(cat);
????outlinePaint = getSectionOutlinePaint(cat);
????outlineStroke = getSectionOutlineStroke(cat);
????drawSide(g2, pieArea, segment, front, back, paint,
??????outlinePaint, outlineStroke, true, false);
???}
???cat++;
??}
??g2.setClip(oldClip);
??// 畫出3D餅圖上部的橢圓的弧形和相關(guān)的標(biāo)簽鏈接和底部的說明(tooltip)
??Arc2D upperArc;
??for (int sectionIndex = 0; sectionIndex < categoryCount; sectionIndex++) {
???//取出弧形
???arc = (Arc2D.Double) arcList.get(sectionIndex);
???if (arc == null) {
????continue;
???}
???//定義3D餅圖上部的橢圓的弧形
???upperArc = new Arc2D.Double(arcX, arcY, pieArea.getWidth(), pieArea
?????.getHeight()
?????- depth,
?????arc.getAngleStart(), //開始角度
?????arc.getAngleExtent(), //角度大小
?????Arc2D.PIE);
???//g2圖形對象所需的油漆桶
???paint = getSectionPaint(sectionIndex);
???//g2圖形對象所需的輪廓油漆桶
???outlinePaint = getSectionOutlinePaint(sectionIndex);
???//g2圖形對象所需的輪廓樣式
???outlineStroke = getSectionOutlineStroke(sectionIndex);
???g2.setPaint(paint);
???//往g2圖形對象中填充弧形
???g2.fill(upperArc);
???g2.setStroke(outlineStroke);
???g2.setPaint(outlinePaint);
???//繪制弧形
???g2.draw(upperArc);
???// 為該部分弧形添加說明欄(tooltip)和url鏈接
???Comparable currentKey = (Comparable) sectionKeys.get(sectionIndex);
???if (info != null) {
????EntityCollection entities = info.getOwner()
??????.getEntityCollection();
????if (entities != null) {
?????String tip = null;
?????PieToolTipGenerator tipster = getToolTipGenerator();
?????if (tipster != null) {
??????// @mgs: using the method's return value was missing
??????tip = tipster.generateToolTip(dataset, currentKey);
?????}
?????String url = null;
?????if (getURLGenerator() != null) {
??????url = getURLGenerator().generateURL(dataset,
????????currentKey, getPieIndex());
?????}
?????PieSectionEntity entity = new PieSectionEntity(upperArc,
???????dataset, getPieIndex(), sectionIndex, currentKey,
???????tip, url);
?????entities.add(entity);
????}
???}
???
???List keys = dataset.getKeys();
???//繪制標(biāo)簽的長方形
???Rectangle2D adjustedPlotArea = new Rectangle2D.Double(
?????originalPlotArea.getX(), originalPlotArea.getY(),
?????originalPlotArea.getWidth(), originalPlotArea.getHeight()
???????- depth);
???//繪制標(biāo)簽(如:Perl=1的Textbox)
???drawLabels(g2, keys, totalValue, adjustedPlotArea, linkArea, state);
??}
??g2.setClip(savedClip);
??g2.setComposite(originalComposite);
??//繪制輪廓
??drawOutline(g2, originalPlotArea);
?}
?
4.3D柱狀圖的繪制函數(shù)(現(xiàn)在的注釋還不夠全面,也可能存在錯誤)
??? /**
???? * Draws a 3D bar to represent one data item.
???? *
???? * @param g2? the graphics device.
???? * @param state? the renderer state.
???? * @param dataArea? the area for plotting the data.
???? * @param plot? the plot.
???? * @param domainAxis? the domain axis.
???? * @param rangeAxis? the range axis.
???? * @param dataset? the dataset.
???? * @param row? the row index (zero-based).
???? * @param column? the column index (zero-based).
???? * @param pass? the pass index.
???? */
??? public void drawItem(Graphics2D g2,
???????????????????????? CategoryItemRendererState state,
???????????????????????? Rectangle2D dataArea,
???????????????????????? CategoryPlot plot,
???????????????????????? CategoryAxis domainAxis,
???????????????????????? ValueAxis rangeAxis,
???????????????????????? CategoryDataset dataset,
???????????????????????? int row,
???????????????????????? int column,
???????????????????????? int pass) {
???
??????? // check the value we are plotting...
??????? Number dataValue = dataset.getValue(row, column);
??????? if (dataValue == null) {
??????????? return;
??????? }
???????
??????? double value = dataValue.doubleValue();
???????
??????? Rectangle2D adjusted = new Rectangle2D.Double(
??????????? dataArea.getX(),
??????????? dataArea.getY() + getYOffset(),
??????????? dataArea.getWidth() - getXOffset(),
??????????? dataArea.getHeight() - getYOffset()
??????? );
??????? PlotOrientation orientation = plot.getOrientation();
???????
??????? double barW0 = calculateBarW0(
??????????? plot, orientation, adjusted, domainAxis, state, row, column
??????? );
??????? double[] barL0L1 = calculateBarL0L1(value);
??????? if (barL0L1 == null) {
??????????? return;? // the bar is not visible
??????? }
??????? RectangleEdge edge = plot.getRangeAxisEdge();
??????? double transL0 = rangeAxis.valueToJava2D(barL0L1[0], adjusted, edge);
??????? double transL1 = rangeAxis.valueToJava2D(barL0L1[1], adjusted, edge);
??????? double barL0 = Math.min(transL0, transL1);
??????? double barLength = Math.abs(transL1 - transL0);
???????
??????? // draw the bar...
??????? //柱子的正視圖
??????? Rectangle2D bar = null;
??????? if (orientation == PlotOrientation.HORIZONTAL) {
??????????? bar = new Rectangle2D.Double(
??????????????? barL0, barW0, barLength, state.getBarWidth()
??????????? );
??????? }
??????? else {
??????????? bar = new Rectangle2D.Double(
??????????????? barW0, barL0, state.getBarWidth(), barLength
??????????? );
??????? }
??????? Paint itemPaint = getItemPaint(row, column);
??????? g2.setPaint(itemPaint);
??????? g2.fill(bar);
??????? // 柱子的俯視圖上的四個點(diǎn)的x坐標(biāo)值
??????? double x0 = bar.getMinX();
??????? double x1 = x0 + getXOffset(); //x0+12
??????? double x2 = bar.getMaxX();
??????? double x3 = x2 + getXOffset(); //x2+12
??????? // 柱子的右視圖上的四個點(diǎn)的y坐標(biāo)值
??????? double y0 = bar.getMinY() - getYOffset(); //正視圖的最小y值-8
??????? double y1 = bar.getMinY();
??????? double y2 = bar.getMaxY() - getYOffset(); //正視圖的最大y值-8
??????? double y3 = bar.getMaxY();
???????
??????? GeneralPath bar3dRight = null;
??????? GeneralPath bar3dTop = null;
??????? // 柱子的右視圖
??????? if (barLength > 0.0) {
??????????? bar3dRight = new GeneralPath();
??????????? bar3dRight.moveTo((float) x2, (float) y3);
??????????? bar3dRight.lineTo((float) x2, (float) y1);
??????????? bar3dRight.lineTo((float) x3, (float) y0);
??????????? bar3dRight.lineTo((float) x3, (float) y2);
??????????? bar3dRight.closePath();
??????????? if (itemPaint instanceof Color) {
??????????????? g2.setPaint(((Color) itemPaint).darker());
??????????? }
??????????? g2.fill(bar3dRight);
??????? }
??????? // 柱子的俯視圖
??????? bar3dTop = new GeneralPath();
??????? bar3dTop.moveTo((float) x0, (float) y1);
??????? bar3dTop.lineTo((float) x1, (float) y0);
??????? bar3dTop.lineTo((float) x3, (float) y0);
??????? bar3dTop.lineTo((float) x2, (float) y1);
??????? bar3dTop.closePath();
??????? g2.fill(bar3dTop);
??????? //繪制3D柱狀圖
??????? if (isDrawBarOutline()
??????????????? && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) {
??????????? g2.setStroke(getItemOutlineStroke(row, column));
??????????? g2.setPaint(getItemOutlinePaint(row, column));
??????????? g2.draw(bar);
??????????? if (bar3dRight != null) {
??????????????? g2.draw(bar3dRight);
??????????? }
??????????? if (bar3dTop != null) {
??????????????? g2.draw(bar3dTop);
??????????? }
??????? }
??????? //繪制標(biāo)簽
??????? CategoryItemLabelGenerator generator
??????????? = getItemLabelGenerator(row, column);
??????? if (generator != null && isItemLabelVisible(row, column)) {
??????????? drawItemLabel(
??????????????? g2, dataset, row, column, plot, generator, bar, (value < 0.0)
??????????? );
??????? }???????
??????? // add an item entity, if this information is being collected
??????? EntityCollection entities = state.getEntityCollection();
??????? if (entities != null) {
??????????? GeneralPath barOutline = new GeneralPath();
??????????? barOutline.moveTo((float) x0, (float) y3);
??????????? barOutline.lineTo((float) x0, (float) y1);
??????????? barOutline.lineTo((float) x1, (float) y0);
??????????? barOutline.lineTo((float) x3, (float) y0);
??????????? barOutline.lineTo((float) x3, (float) y2);
??????????? barOutline.lineTo((float) x2, (float) y3);
??????????? barOutline.closePath();
??????????? addItemEntity(entities, dataset, row, column, barOutline);
??????? }
??? }
String usercodemessage = "";
?/**
? * 搜尋父結(jié)點(diǎn)(獲得用戶部門信息)
? */
?public String searchTreeFatherNood(TCsDept tCsDept) {??
??if (tCsDept.getFathercode().equals("")) {
???usercodemessage = tCsDept.getDeptname() + "/" + usercodemessage;
??} else {
???usercodemessage = tCsDept.getDeptname() + "/" + usercodemessage;
???TCsDept tCsDept2 = (TCsDept) userDao.fetchQuerister().loadObject(
?????TCsDept.class, tCsDept.getFathercode());???
???searchTreeFatherNood(tCsDept2);
??}
??return usercodemessage;
?}