帮我弄出一个程序流程图或者是一段说明性文字和一些输入、输出的例子,对此段代码的处理过程,具体产生的结果进行说明

East271536394 2008-06-01 01:46:08
use LWP 5.64;

use Data::Dumper qw(Dumper);

use HTML::TreeBuilder;
use HTML::Element;
use HTML::Parse;
my $browser = LWP::UserAgent->new;

my $url = ‘http://url?para=’;

$n=1;
$pages=80;

print “<table>”;

for($n=1;$n <=$pages;$n++){

my $purl = $url.$n;
my $response = $browser->get( $purl );

die “不能打开 $url — “, $response->status_line
unless $response->is_success;

die “不支持格式”, $response->content_type
unless $response->content_type eq ‘text ml’;

$html = $response->content;


@result = $html =~m/<table[^>]*>(.*?)<\/table>/isg;

$i=1;//行号
$j=1;//列号
foreach my $table (@result){

@trs = $table =~m/<tr[^>]*>(.*?)<\/tr>/isg;

foreach my $row (@trs){
@tds = $row =~m/<td[^>]*>(.*?)<\/td>/isg;

print “<tr>”;
foreach my $cell(@tds){
$cell =~s/<.*?>//;
print “<td>”;
print $cell;
print “</td>”;
}
print “</tr>”;
$j++;

}
$i++;
}

sleep(5); //

}

print “</table>”;
...全文
361 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
East271536394 2009-08-22
  • 打赏
  • 举报
回复
private byte[] drewPic() throws IOException
{
JFreeChart chart = ChartFactory.createBarChart(getTitle(), getXLineLabel(), // x的显示标签
getYLineLabel(), // y的显示标签
getDataset(), // 数据集
PlotOrientation.VERTICAL, // 图表方向:水平、垂直
isShowLegend(), // 是否显示图例(对于简单的柱状图必须是false)
true, // 是否生成工具
false // 是否生成URL链接
);
// 设置整个chart的背景颜色
chart.setBackgroundPaint(getBackGroundColor());
CategoryPlot plot = chart.getCategoryPlot();
plot.setBackgroundPaint(getBackGroundColor());
// 设置目标轴线条颜色
plot.setDomainGridlinePaint(getXLineColor());
// 设置目标轴线条是否可见,默认是不可见的
plot.setDomainGridlinesVisible(isShowGrid());
// 设置数据轴线条颜色
plot.setRangeGridlinePaint(getYLineColor());
plot.setRangeGridlinesVisible(isShowGrid());
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
BarRenderer renderer = (BarRenderer) plot.getRenderer();
// 是否显示条形的边框
renderer.setDrawBarOutline(isShowShapeBorder());
renderer.setBaseItemURLGenerator(new StandardCategoryURLGenerator());
renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator("{3}", new DecimalFormat("0.0%")));
renderer.setBaseItemLabelFont(getLabelFont());
renderer.setBaseItemLabelsVisible(isShowItemLabel());
renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator("{0}:{2}", new DecimalFormat()));
setRendererColor(renderer, getColorList());
BufferedImage bi = chart.createBufferedImage(Integer.parseInt(getWidth()), Integer.parseInt(getHeight()),
Transparency.TRANSLUCENT, jfinfo);
for (Iterator it = jfinfo.getEntityCollection().iterator(); it.hasNext();)
{
Object ce = (Object) it.next();
if (ce.getClass().equals(CategoryItemEntity.class))
{
CategoryItemEntity entity = (CategoryItemEntity) ce;
CustomArea area = new CustomArea();
area.setTooltiptext(entity.getToolTipText());
area
.setEntity(getEntityByRowAndColName(entity.getRowKey().toString(), entity.getColumnKey().toString()));
area.setCoords(entity.getShapeCoords());
area.setShape(entity.getShapeType());
super.appendChild(area);
}
}
return EncoderUtil.encode(bi, ImageFormat.PNG, true);

}
private CustomerSLAAvalibitlityEntity getEntityByRowAndColName(String rowName, String colName)
{
CustomerSLAAvalibitlityEntity customerSLAAvalibitlityEntity = null;
for (CustomerSLAAvalibitlityEntity entity : getDataEntityList())
{
if (entity.getStatus().equals(rowName) && entity.getType().equals(colName))
{

customerSLAAvalibitlityEntity = entity;
break;
}

}
return customerSLAAvalibitlityEntity;

}
East271536394 2009-08-22
  • 打赏
  • 举报
回复
public class CustomBarCharts extends Imagemap
{

/**
* 数据对象集合
*/
private List<CustomerSLAAvalibitlityEntity> dataEntityList;

public List<CustomerSLAAvalibitlityEntity> getDataEntityList()
{
return dataEntityList;
}

public void setDataEntityList(List<CustomerSLAAvalibitlityEntity> dataEntityList)
{
this.dataEntityList = dataEntityList;
}


public void showChart() throws IOException
{
final AImage image = new AImage("chart" + new Date().getTime(), drewPic());

setContent(image);
super.addEventListener("onClick", new EventListener()
{

@SuppressWarnings("unchecked")
@Override
public void onEvent(Event arg0) throws Exception
{
org.zkoss.zk.ui.event.MouseEvent ee = (org.zkoss.zk.ui.event.MouseEvent) arg0;

for (Object obj : arg0.getTarget().getChildren())
{
CustomArea area = (CustomArea) obj;
if (ee.getArea().equals(area.getId()))
{
CustomerSLAAvalibitlityEntity entity = area.getEntity();

Map parm = new HashMap();
List<Long> slaList = entity.getSlaId();
parm.put("slaList", slaList);
parm.put("moId", entity.getMoId());

MenuDto evtData = new MenuDto();
evtData.setArgs(parm);
if (entity.getType().toString().contains("SLA"))
{
evtData.setBookmark("客户 SLAs");
}
else
{
evtData.setBookmark("当前阈值告警");
}

evtData.setZulpath(entity.getUrl());
Tabbox mainTabbox = (Tabbox) Executions.getCurrent().getDesktop().getAttribute(
"menuMain_tabbox");
if (mainTabbox != null)
{
Events.postEvent("onChangePage", mainTabbox, evtData);
}
break;
}
}
}
});

}

private DefaultCategoryDataset getDataset()
{
DefaultCategoryDataset dataSet = new DefaultCategoryDataset();
for (CustomerSLAAvalibitlityEntity entity : getDataEntityList())
{
dataSet.addValue(entity.getAmount(), entity.getStatus(), entity.getType());
}

return dataSet;

}
East271536394 2009-08-11
  • 打赏
  • 举报
回复
public ArrayList<PlotData> generateData(long days)
{
Date now = new Date();
Date startTime = new Date(now.getTime()-days*86400*1000);
ArrayList<PlotData> datas = new ArrayList<PlotData>();
while(startTime.before(now))
{
PlotData data = new PlotData();
startTime.setTime(startTime.getTime()+900000);
data.setTime(new Date(startTime.getTime()));
Random x = new Random();
float radomValue=x.nextFloat()*100;
radomValue = (radomValue < 40)? radomValue + 40 : radomValue;
data.setValue(radomValue);
datas.add(data);
}
return datas;
}

<timeplot id="MetricBrowser_plot" width="100%" height="200px"></timeplot>

10,606

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 其他
社区管理员
  • 其他
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧