August 16, 2017
Posted by on
Hibernate doesn’t provide function to check existing alias. If you try to add the same alias to the criteria, you will get exception: duplicate association path.
The solution is to create a set and record all exisitng alias. We only add new alias if it’s not in the set.
private List<String> aliasValues = new ArrayList<>();
August 15, 2017
Posted by on
I just finished a task: load an image inside a popup canvas then draw lines on the canvas and save the image data. I had a couple issues during the development, but luckily I managed to find answers on google.
- How to draw on canvas on mobile devices.
I found a good article which give all the details Using Touch Events with the HTML5 Canvas. You should be aware of the difference code for IOS,Android and canvas in browser. The touch devices use “touchmove”,”touchstart” while the browswer uses “mousemove”,”mousedown”..etc
- We need to stop page scrolling when user are ready for drawing.
stopScroll = (ev) ->
$page.on("popupbeforeposition","#popupPanel", (event,ui) ->
- How to improve image quality.
When loading the photo to canvas, you may get a blurry image. The following code improve the quality of image
canvastx = popupCanvas.getContext("2d");
canvastx.webkitImageSmoothingEnabled = false;
canvastx.mozImageSmoothingEnabled = false;
canvastx.imageSmoothingEnabled = false;
- Don’t resize canvas, you should always create new one.
Make sure you create new canvas after reading the image info. This way you know the image demision, then you could create new canvas with the same width/height ratio. If you draw on a resized canvas, everything(x,y point) on that canvas will be scaled. You will have to do some calculation to get the orginal point. That’s why I prefer creating a new canvas with the right size.