Commit 6522b5e0 authored by wuqinghua's avatar wuqinghua

2021/12/7 吴卿华 1修改一级关系图展示形状为圆形 2修改颜色生成算法

parent 9f85871b
package com.example.gajz.transferrelationship;
import org.junit.Test;
import java.awt.*;
import java.util.Random;
public class TEST {
public static void main(String[] args) {
}
@Test
public void RandomHexColor_test() {
Random random = new Random();
float hue = random.nextFloat();
float saturation = (random.nextInt(7000) + 4000) / 10000f;
float luminance = 1f;
Color color = Color.getHSBColor(hue, saturation, luminance);
System.out.println(color);
System.out.println("#" + Integer.toHexString((color.getRGB() & 0xffffff) | 0x1000000).substring(1));
//红色
String red;
//绿色
String green;
//蓝色
String blue;
//生成红色颜色代码
red = Integer.toHexString(random.nextInt(256)).toUpperCase();
//生成绿色颜色代码
green = Integer.toHexString(random.nextInt(256)).toUpperCase();
//生成蓝色颜色代码
blue = Integer.toHexString(random.nextInt(256)).toUpperCase();
//判断红色代码的位数
red = red.length()==1 ? "0" + red : red ;
//判断绿色代码的位数
green = green.length()==1 ? "0" + green : green ;
//判断蓝色代码的位数
blue = blue.length()==1 ? "0" + blue : blue ;
//生成十六进制颜色值
String color1 = "0x"+red+green+blue;
System.out.println(color1);
}
}
package com.example.gajz.transferrelationship.neo4j; package com.example.gajz.transferrelationship.neo4j;
import java.awt.*;
import java.util.Random; import java.util.Random;
public class Colour { public class Colour {
public String getColour(){ public String getColour(){
//红色 // //红色
String red; // String red;
//绿色 // //绿色
String green; // String green;
//蓝色 // //蓝色
String blue; // String blue;
//生成随机对象 //生成随机对象
Random random = new Random(); Random random = new Random();
//生成红色颜色代码 // //生成红色颜色代码
red = Integer.toHexString(random.nextInt(256)).toUpperCase(); // red = Integer.toHexString(random.nextInt(256)).toUpperCase();
//生成绿色颜色代码 // //生成绿色颜色代码
green = Integer.toHexString(random.nextInt(256)).toUpperCase(); // green = Integer.toHexString(random.nextInt(256)).toUpperCase();
//生成蓝色颜色代码 // //生成蓝色颜色代码
blue = Integer.toHexString(random.nextInt(256)).toUpperCase(); // blue = Integer.toHexString(random.nextInt(256)).toUpperCase();
//判断红色代码的位数 // //判断红色代码的位数
red = red.length()==1 ? "0" + red : red ; // red = red.length()==1 ? "0" + red : red ;
//判断绿色代码的位数 // //判断绿色代码的位数
green = green.length()==1 ? "0" + green : green ; // green = green.length()==1 ? "0" + green : green ;
//判断蓝色代码的位数 // //判断蓝色代码的位数
blue = blue.length()==1 ? "0" + blue : blue ; // blue = blue.length()==1 ? "0" + blue : blue ;
//生成十六进制颜色值 // //生成十六进制颜色值
String color = "0x"+red+green+blue; // String color = "0x"+red+green+blue;
return color;
float hue = random.nextFloat();
float saturation = (random.nextInt(7000) + 4000) / 10000f;
float luminance = 1f;
Color color1= Color.getHSBColor(hue, saturation, luminance);
String cos="0x" + Integer.toHexString((color1.getRGB() & 0xffffff) | 0x1000000).substring(1);
return cos;
} }
} }
...@@ -2,22 +2,35 @@ package com.example.gajz.transferrelationship.neo4j; ...@@ -2,22 +2,35 @@ package com.example.gajz.transferrelationship.neo4j;
import com.example.gajz.redis.ConFigRedis; import com.example.gajz.redis.ConFigRedis;
import redis.clients.jedis.Jedis; import redis.clients.jedis.Jedis;
import java.util.HashMap; import java.util.*;
import java.util.Set;
public class test { public class test {
public static void main(String[] args) { public static void main(String[] args) {
int START = 1;
int END = 100;
Random random = new Random();
for (int idx = 1; idx <= 1; ++idx){
showRandomInteger(START, END, random);
}
}
HashMap hashMap=new HashMap(); private static void showRandomInteger(int aStart, int aEnd, Random aRandom){
hashMap.put("1","111"); if ( aStart > aEnd ) {
hashMap.put("2","222"); throw new IllegalArgumentException("Start cannot exceed End.");
hashMap.put("3","333"); }
hashMap.put("4","444"); //get the range, casting to long to avoid overflow problems
long range = (long)aEnd - (long)aStart + 1;
// compute a fraction of the range, 0 <= frac < range
long fraction = (long)(range * aRandom.nextDouble());
int randomNumber = (int)(fraction + aStart);
log("Generated : " + randomNumber);
}
private static void log(String aMessage){
System.out.println(aMessage);
}
System.out.println(hashMap.size());
}
} }
...@@ -273,8 +273,8 @@ public class CalculationCenterPoint { ...@@ -273,8 +273,8 @@ public class CalculationCenterPoint {
CenterPointVo centerPointVo1=new CenterPointVo(); CenterPointVo centerPointVo1=new CenterPointVo();
centerPointVo1.setBankCardNo(transferCardVoList.get(p).getBankCardNo()); centerPointVo1.setBankCardNo(transferCardVoList.get(p).getBankCardNo());
centerPointVo1.setName(transferCardVoList.get(p).getName()); centerPointVo1.setName(transferCardVoList.get(p).getName());
centerPointVo1.setX((int)(Math.random()*2000)); centerPointVo1.setX((int)(Math.random()*1000));
centerPointVo1.setY((int)(Math.random()*2000)); centerPointVo1.setY((int)(Math.random()*1000));
temporaryList.add(centerPointVo1); temporaryList.add(centerPointVo1);
repeat.put(transferCardVoList.get(p).getBankCardNo(),1); repeat.put(transferCardVoList.get(p).getBankCardNo(),1);
} }
...@@ -294,11 +294,8 @@ public class CalculationCenterPoint { ...@@ -294,11 +294,8 @@ public class CalculationCenterPoint {
subordinateList.add(temporary.get(x)); subordinateList.add(temporary.get(x));
} }
} }
} }
return centerPointVoList; return centerPointVoList;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment