|
|
@ -4,12 +4,9 @@ import com.fr.base.BaseUtils; |
|
|
|
import com.fr.general.FArray; |
|
|
|
import com.fr.general.FArray; |
|
|
|
import com.fr.general.GeneralUtils; |
|
|
|
import com.fr.general.GeneralUtils; |
|
|
|
import com.fr.locale.InterProviderFactory; |
|
|
|
import com.fr.locale.InterProviderFactory; |
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
|
|
|
|
import com.fr.plugin.context.PluginContexts; |
|
|
|
|
|
|
|
import com.fr.plugin.cool.cartnoon.utils.AnimatedGifEncoder; |
|
|
|
import com.fr.plugin.cool.cartnoon.utils.AnimatedGifEncoder; |
|
|
|
import com.fr.plugin.cool.cartnoon.web.ImageViewer; |
|
|
|
import com.fr.plugin.cool.cartnoon.web.ImageViewer; |
|
|
|
import com.fr.script.AbstractFunction; |
|
|
|
import com.fr.script.AbstractFunction; |
|
|
|
import com.fr.script.Calculator; |
|
|
|
|
|
|
|
import com.fr.stable.ColumnRow; |
|
|
|
import com.fr.stable.ColumnRow; |
|
|
|
import com.fr.stable.fun.Authorize; |
|
|
|
import com.fr.stable.fun.Authorize; |
|
|
|
import sun.font.FontDesignMetrics; |
|
|
|
import sun.font.FontDesignMetrics; |
|
|
@ -21,18 +18,13 @@ import java.awt.image.BufferedImage; |
|
|
|
import java.io.ByteArrayOutputStream; |
|
|
|
import java.io.ByteArrayOutputStream; |
|
|
|
import java.io.File; |
|
|
|
import java.io.File; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.IOException; |
|
|
|
import java.net.MalformedURLException; |
|
|
|
|
|
|
|
import java.net.URL; |
|
|
|
|
|
|
|
import java.util.regex.Matcher; |
|
|
|
import java.util.regex.Matcher; |
|
|
|
import java.util.regex.Pattern; |
|
|
|
import java.util.regex.Pattern; |
|
|
|
|
|
|
|
|
|
|
|
@Authorize(callSignKey = FunConstants.PLUGIN_ID) |
|
|
|
@Authorize(callSignKey = CartUtils.PLUGIN_ID) |
|
|
|
public class FunConstants { |
|
|
|
public class CartUtils { |
|
|
|
|
|
|
|
|
|
|
|
static final String PLUGIN_ID = "com.fr.plugin.cool.cartnoon"; |
|
|
|
static final String PLUGIN_ID = "com.fr.plugin.cool.cartnoon"; |
|
|
|
static final String AUTHOR_ERROR = InterProviderFactory.getProvider().getLocText("Plugin.Function.CartNoon_AUTHOR_ERROR"); |
|
|
|
|
|
|
|
static boolean Author() { |
|
|
|
|
|
|
|
return PluginContexts.currentContext().isAvailable(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static boolean CheckArgs(Object[] args,int num) { |
|
|
|
static boolean CheckArgs(Object[] args,int num) { |
|
|
|
return args.length==num; |
|
|
|
return args.length==num; |
|
|
@ -67,7 +59,7 @@ public class FunConstants { |
|
|
|
int textHeight=fm.getHeight(); |
|
|
|
int textHeight=fm.getHeight(); |
|
|
|
BufferedImage img = new BufferedImage(width, textHeight, BufferedImage.TYPE_4BYTE_ABGR); |
|
|
|
BufferedImage img = new BufferedImage(width, textHeight, BufferedImage.TYPE_4BYTE_ABGR); |
|
|
|
Graphics2D g2 = img.createGraphics(); |
|
|
|
Graphics2D g2 = img.createGraphics(); |
|
|
|
FineLoggerFactory.getLogger().info("textWidth,textHeightY:{},{}",textWidth,textHeight); |
|
|
|
|
|
|
|
AffineTransform affineTransform = new AffineTransform(); |
|
|
|
AffineTransform affineTransform = new AffineTransform(); |
|
|
|
Font rotatedFont = font.deriveFont(affineTransform); |
|
|
|
Font rotatedFont = font.deriveFont(affineTransform); |
|
|
|
g2.setFont(rotatedFont); |
|
|
|
g2.setFont(rotatedFont); |
|
|
@ -87,7 +79,7 @@ public class FunConstants { |
|
|
|
|
|
|
|
|
|
|
|
BufferedImage img = new BufferedImage(textWidth, textWidth, BufferedImage.TYPE_4BYTE_ABGR); |
|
|
|
BufferedImage img = new BufferedImage(textWidth, textWidth, BufferedImage.TYPE_4BYTE_ABGR); |
|
|
|
Graphics2D g2 = img.createGraphics(); |
|
|
|
Graphics2D g2 = img.createGraphics(); |
|
|
|
FineLoggerFactory.getLogger().info("textWidth,textHeightY:{},{}",textWidth,textHeight); |
|
|
|
|
|
|
|
AffineTransform affineTransform = new AffineTransform(); |
|
|
|
AffineTransform affineTransform = new AffineTransform(); |
|
|
|
Font rotatedFont = font.deriveFont(affineTransform); |
|
|
|
Font rotatedFont = font.deriveFont(affineTransform); |
|
|
|
g2.setFont(rotatedFont); |
|
|
|
g2.setFont(rotatedFont); |
|
|
@ -97,31 +89,7 @@ public class FunConstants { |
|
|
|
return img; |
|
|
|
return img; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
final static void CreatePrintAnimate(String id, String text, int fontSize, int rate, Color color, int width) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 读数据
|
|
|
|
|
|
|
|
int len=text.length(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AnimatedGifEncoder e = new AnimatedGifEncoder(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ByteArrayOutputStream out=new ByteArrayOutputStream(); |
|
|
|
|
|
|
|
e.start(out); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//图片之间间隔时间
|
|
|
|
|
|
|
|
e.setDelay(rate); // 1 frame per sec
|
|
|
|
|
|
|
|
//重复次数 0表示无限重复 默认不重复
|
|
|
|
|
|
|
|
e.setRepeat(0); |
|
|
|
|
|
|
|
//添加图片
|
|
|
|
|
|
|
|
String subStr; |
|
|
|
|
|
|
|
for (int i = 0; i <= len; i++) { |
|
|
|
|
|
|
|
subStr=text.substring(0,i); |
|
|
|
|
|
|
|
e.addFrame(ImageFromText(subStr,fontSize,color,width)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
e.finish(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
byte[] data = out.toByteArray(); |
|
|
|
|
|
|
|
ImageViewer.gifData.put(id,data); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
final static void CreateCountUpAnimate(String id, Integer number, int fontSize, int rate, Color color, int width) { |
|
|
|
final static void CreateCountUpAnimate(String id, Integer number, int fontSize, int rate, Color color, int width) { |
|
|
|
|
|
|
|
|
|
|
|
// 读数据
|
|
|
|
// 读数据
|
|
|
@ -129,7 +97,6 @@ public class FunConstants { |
|
|
|
int step=number/len; |
|
|
|
int step=number/len; |
|
|
|
|
|
|
|
|
|
|
|
AnimatedGifEncoder e = new AnimatedGifEncoder(); |
|
|
|
AnimatedGifEncoder e = new AnimatedGifEncoder(); |
|
|
|
|
|
|
|
|
|
|
|
ByteArrayOutputStream out=new ByteArrayOutputStream(); |
|
|
|
ByteArrayOutputStream out=new ByteArrayOutputStream(); |
|
|
|
e.start(out); |
|
|
|
e.start(out); |
|
|
|
|
|
|
|
|
|
|
@ -149,7 +116,6 @@ public class FunConstants { |
|
|
|
ImageViewer.gifData.put(id,data); |
|
|
|
ImageViewer.gifData.put(id,data); |
|
|
|
} |
|
|
|
} |
|
|
|
static String GetCellId(AbstractFunction calculator){ |
|
|
|
static String GetCellId(AbstractFunction calculator){ |
|
|
|
String[] result={}; |
|
|
|
|
|
|
|
final ColumnRow currentColumnRow = calculator.getCalculator().getCurrentColumnRow(); |
|
|
|
final ColumnRow currentColumnRow = calculator.getCalculator().getCurrentColumnRow(); |
|
|
|
int intRow=currentColumnRow.getRow(); |
|
|
|
int intRow=currentColumnRow.getRow(); |
|
|
|
int intCol=currentColumnRow.getColumn(); |
|
|
|
int intCol=currentColumnRow.getColumn(); |
|
|
@ -159,9 +125,6 @@ public class FunConstants { |
|
|
|
} |
|
|
|
} |
|
|
|
static BufferedImage readImage(Object file) { |
|
|
|
static BufferedImage readImage(Object file) { |
|
|
|
BufferedImage res=null; |
|
|
|
BufferedImage res=null; |
|
|
|
// if (file instanceof BufferedImage) {
|
|
|
|
|
|
|
|
// return (BufferedImage) file;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
String filename = file.toString(); |
|
|
|
String filename = file.toString(); |
|
|
|
if(isHttpUrl(filename)){ |
|
|
|
if(isHttpUrl(filename)){ |
|
|
|
res= BaseUtils.readImage(filename); |
|
|
|
res= BaseUtils.readImage(filename); |